I use below code to send mail with attachments from a Lotus Notes client to internet mailboxes.
All of other mailboxes work well with this code, however when my mail send to Microsoft Exchange 2010 and Outlook the attachment has been parsed to garbled languages in text body. I tried many ways but couldn't fix.
I need an urgent suppport from you to help me fix this issue.
Domino.NotesDocument oNotesDocument = null;
object oItemValue = null;
try
{
oNotesDocument = m_notesDatabase.CreateDocument();
oNotesDocument.ReplaceItemValue("Form", "Memo");
oNotesDocument.ReplaceItemValue("From", msgData.FromMail);
oNotesDocument.ReplaceItemValue("SendTo",
msgData.ToMail.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
if (!String.IsNullOrEmpty(msgData.ReplyTo))
{
oNotesDocument.ReplaceItemValue("ReplyTo", msgData.ReplyTo);
}
if (!String.IsNullOrEmpty(msgData.Principal))
{
oNotesDocument.ReplaceItemValue("Principal", msgData.Principal);
}
if (!string.IsNullOrEmpty(msgData.CcAddresses))
{
oNotesDocument.ReplaceItemValue("CopyTo",
msgData.CcAddresses.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
}
oNotesDocument.ReplaceItemValue("Subject", msgData.Subject);
Domino.NotesRichTextItem rtItem = oNotesDocument.CreateRichTextItem("Body");
FormatMessge(rtItem, msgData.Body);
rtItem.AddNewLine(2, true);
if (msgData.AttachedFile != null)
{
foreach (string fileName in msgData.AttachedFile)
{
rtItem.EmbedObject(EMBED_TYPE.EMBED_ATTACHMENT, "",
fileName, "");
}
}
oNotesDocument.SaveMessageOnSend = true;
oNotesDocument.ReplaceItemValue("postDate", DateTime.Now);
oItemValue = oNotesDocument.GetItemValue("SendTo");
return true;
}
catch (System.Exception error)
{
throw error;
}
finally
{
oNotesDocument = null;
oItemValue = null;
GC.Collect();
}