DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Using VB.NET To Check for Proxy and VPN With IP2Location.io Geolocation API
  • How To Get Cell Data From an Excel Spreadsheet Using APIs in Java
  • 8 Strategies To Accelerate Web Portal Development
  • A Better Web3 Experience: Account Abstraction From Flow (Part 1)

Trending

  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice
  • Why I Started Using Dependency Injection in Python
  • Comparing SaaS vs. PaaS for Kafka and Flink Data Streaming
  • Emerging Data Architectures: The Future of Data Management

How to Send Email Messages using Exchange Server & Exchange Web Services Using C# & VB.NET

By 
David Zondray user avatar
David Zondray
·
Apr. 20, 14 · Code Snippet
Likes (0)
Comment
Save
Tweet
Share
40.1K Views

Join the DZone community and get the full member experience.

Join For Free

This technical tip explains how to send email messages using exchange server & exchange web services inside .NET applications. You can send email messages using Exchange Server with the help of the tools in the Aspose.Email.Exchange. The ExchangeClient.Send() method accepts a MailMessage instance as a parameter and sends the email. Please follow the following steps to send emails using Exchange Server:

  • Create an instance of the ExchangeClient class.
  • Specify server name, username, password and domain.
  • Create an instance of the MailMessage class.
  • Specify the from, to, subject and other MailMessage properties.
  • Call the ExchangeClient.Send() method to send the email.
//The sample code below sends email messages using Exchange Server.

//[C# Code Sample]

/ Create instance of ExchangeClient class by giving credentials
ExchangeClient client = new ExchangeClient("http://MachineName/exchange/username",
    "username", "password", "domain");

// Create instance of type MailMessage
MailMessage msg = new MailMessage();
msg.From = "sender@domain.com";
msg.To = "recipient@ domain.com ";
msg.Subject = "Sending message from exchange server";
msg.HtmlBody = "  

sending message from exchange server

"; // Send the message client.Send(msg); //[VB.NET Code Sample] ‘Create instance of ExchangeClient class by giving credentials Dim client As ExchangeClient = New ExchangeClient("http://MachineName/exchange/username", "username", "password", "domain") ' Create instance of type MailMessage Dim msg As MailMessage = New MailMessage() msg.From = "sender@domain.com" msg.To = "recipient@ domain.com " msg.Subject = "Sending message from exchange server" msg.HtmlBody = "

sending message from exchange server

" ' Send the message client.Send(msg) ///Send Email using Exchange Web Services //[C# Code Sample] // Create instance of IEWSClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); // Create instance of type MailMessage MailMessage msg = new MailMessage(); msg.From = "sender@domain.com"; msg.To = "recipient@ domain.com "; msg.Subject = "Sending message from exchange server"; msg.HtmlBody = "

sending message from exchange server

"; // Send the message client.Send(msg); //[VB.NET Code Sample] ' Create instance of EWSClient class by giving credentials Dim client As IEWSClient = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain") ' Create instance of type MailMessage Dim msg As MailMessage = New MailMessage() msg.From = "sender@domain.com" msg.To = "recipient@ domain.com " msg.Subject = "Sending message from exchange server" msg.HtmlBody = "

sending message from exchange server

" ' Send the message client.Send(msg)
VB.NET Web Service

Opinions expressed by DZone contributors are their own.

Related

  • Using VB.NET To Check for Proxy and VPN With IP2Location.io Geolocation API
  • How To Get Cell Data From an Excel Spreadsheet Using APIs in Java
  • 8 Strategies To Accelerate Web Portal Development
  • A Better Web3 Experience: Account Abstraction From Flow (Part 1)

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!