We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Sending email irrespective of viewer


I want to send an email using SMTP but I don’t know what is at the viewer type at the other end i.e. It may support HTML or not. Is there any way that we can specify multiple email content types for sending email irrespective of browsers at receiving end?


Hi Robert,

Thank you for contacting Aspose support team.

You may use alternate views to add plain text and html bodies to display proper body according to the viewer capabilities. Please give a try to the following sample code and share the feedback.

String path = "";
MailMessage SampleMsg = new MailMessage();
SampleMsg.Subject = "Test Email 5.8 with Linked resource in AlternateView";
AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my plain text content", null, "text/plain");
AlternateView htmlView = AlternateView.CreateAlternateViewFromString("Here is an embedded image.", null, "text/html");
LinkedResource logo = new LinkedResource(path + @"Desert.jpg", MediaTypeNames.Image.Jpeg);
logo.ContentId = "companyLogo";
SampleMsg.IsBodyHtml = true;

//Set From, To, ReplyToList
SampleMsg.From = new MailAddress("user1@gmail.com");
SampleMsg.To.Add(new MailAddress("user2@gmail.com"));
MailAddressCollection coll = new MailAddressCollection();
coll.Add(new MailAddress("user3@gmail.com"));

//msgReply.ReplyToList = coll;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "user1@gmail.com", "password", SecurityOptions.Auto);