【C#】Send Email Using Office
>
>
【C#】Send Email Using Office

C# - Send Email Using Office

C# - Send Email Using Office

Learn how to send emails using C# and the Office API. Our step-by-step guide covers everything from setting up SMTP settings to creating and sending an email. Improve your workflow and efficiency.

Table of - contents

No.
Title
1
Using office to send Email

1 - Using office to send Email.

using System.Net;	// Library to Include
using System.Net.Mail;	// Library to Include

// Create a MailMessage object
MailMessage mail = new MailMessage();
mail.From = new MailAddress("YourEmail@company.com");
mail.To.Add("RecipientEmail@company.com");
mail.Subject = "Email Subject";
mail.Body = "Body of the email";

// Create a SmtpClient object with the SMTP settings of your email provider
SmtpClient smtpClient = new SmtpClient("smtp.office365.com", 587);
smtpClient.Credentials = new NetworkCredential("YourEmail@company.com", "YourEmailPassword");
smtpClient.EnableSsl = true;

// Send the email
smtpClient.Send(mail);
In this code, you need to replace “YourEmail@company.com” and “YourEmailPassword” with your actual email address and password. You also need to replace “RecipientEmail@company.com” with the email address of the recipient. Note that the SMTP settings (host and port) may vary depending on your email provider.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Search

.
Xiao. tian
.

Piano - Music

.

Recent - Post

.
0 0 votes
Article Rating

Start typing and press Enter to search

Shopping Cart
0
Would love your thoughts, please comment.x
()
x