Hi,
If i have more inline images say 30 so for adding those images in msg what should i do…
please reply soon
Hi,
Hi Pooja,
You can have a look at the following code sample for your reference. It reads 10 images of JPG type from the folder EMAIL_11111 and adds it to the MailMessage. Please let us know if you have any difficulty in understanding the example. We’ll be glad to assist you further.
Sample Code:
MailMessage mail = new MailMessage();
mail.From = new MailAddress("test001@kerio.com");
mail.To.Add("test001@kerio.com");
mail.Subject = "This is an email";
string strDir = "EMAIL_11111\\";
DirectoryInfo d = new DirectoryInfo(strDir);
String strAllCidString = "";
foreach(var file in d.GetFiles("*.jpg"))
{
strAllCidString = strAllCidString + "<img src=cid:" + file.Name.ToString() + ">\n";
LinkedResource InlineImage = new LinkedResource(strDir + file.Name);
InlineImage.ContentId = file.Name.ToString();
mail.LinkedResources.Add(InlineImage);
}
AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my plain text content", null, "text/plain");
AlternateView htmlView1 = AlternateView.CreateAlternateViewFromString("Here is an embedded image.\n" + strAllCidString, null, "text/html");
mail.AlternateViews.Add(plainView);
mail.AlternateViews.Add(htmlView1);
mail.Save(strDir + "Test.msg", MailMessageSaveType.OutlookMessageFormat);
// You can further add this message to a PST as follow:
MapiMessage mapi = MapiMessage.FromMailMessage(mail);
PersonalStorage pst = PersonalStorage.Create(strDir + "InlineImage.pst", FileFormatVersion.Unicode);
FolderInfo folderInfo = pst.RootFolder.AddSubFolder("Test Folder");
folderInfo.AddMessage(mapi);
Hi,
Hi Pooja,
Hi,
Hi Pooja,