I've tried with only simple text but i want to sent email with attachment.
var emailMessage = new MimeMessage();
emailMessage.From.Add(new MailboxAddress("Test","[email protected]"));
emailMessage.To.Add(new MailboxAddress("Demo", "[email protected]"));
emailMessage.Subject = "Hello";
emailMessage.Body = new TextPart("html") { Text = "Hi............" };
//I want Attachment here with body text..
//Send Email.
using (var client = new SmtpClient())
{
await client.ConnectAsync("smtp.gmail.com", 587, false);
client.AuthenticationMechanisms.Remove("XOAUTH2");
await client.AuthenticateAsync("uid", "pass");
await client.SendAsync(emailMessage);
await client.DisconnectAsync(true);
}
For more detail, Please visit here