Hi,
Hi Sathyapriya,
String path = “”;<o:p></o:p>
MailMessage SampleMsg = new MailMessage();
SampleMsg.Subject = "Test Email 5.7 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";
htmlView.LinkedResources.Add(logo);
SampleMsg.IsBodyHtml = true;
SampleMsg.AlternateViews.Add(plainView);
SampleMsg.AlternateViews.Add(htmlView);
//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.SSLExplicit);
client.Send(SampleMsg);
Thank you for the details.
Hi Sathyapriya,
Please can you share the sample code.
Hi,
I have used the following code at our end which is extension to your sample code provided above.
Code:
Aspose.Words.Document RTFDocument = new Aspose.Words.Document(“test.rtf”);
MemoryStream mhtmlStream = new MemoryStream();
RTFDocument.Save(mhtmlStream, Aspose.Words.SaveFormat.Mhtml);
[//RTFDocument.Save](https://rtfdocument.save/)(“test.mhtml”, Aspose.Words.SaveFormat.Mhtml);
mhtmlStream.Position = 0;
MailMessage SampleMsg = MailMessage.Load(mhtmlStream);
SampleMsg.Save(“RtfMsg.msg”, Aspose.Email.Mail.SaveOptions.DefaultMsgUnicode);//for viewing only
SampleMsg.Subject = “RTF Body Sending Test”;
SampleMsg.To = "to@gmail.com";
SampleMsg.From = "from@gmail.com";
SmtpClient client = GetSmtpClient();//some smtp client
client.Send(SampleMsg);
Thank you.
Hi,
I could get this working by saving the message and loading it again. Please could you let me know if aspose mail could interpret the html body and associated files created using Microsoft.Office.Interop.Word library. If it is possible please could you share a sample code that could do this.
Hi,
Attached is the sample HTML and the associated files generated by Word interop.
Hi Sathyapriya,