I wrote a C# form application, that can send and receive emails using Outlook 2013. I used with MAPI namespeace.( "Outlook._NameSpace _ns = _app.GetNamespace("MAPI");"). My problem is: How create Identifier for email? I would like save it into an sql database table and later recognize if table already contains this mail. I had found mail.CreationTime and mail.SenderEmailAddress, but after send method(in code last rows), mail is already empty. Thanks any helps.
I send my send message code:
Outlook._Application _app = new Outlook.Application();
Outlook._NameSpace _ns = _app.GetNamespace("MAPI");
Outlook.MAPIFolder inbox = _ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MailItem mail = (Outlook.MailItem)_app.CreateItem(Outlook.OlItemType.olMailItem);
mail.To = ActEmail.To;
mail.CC = ActEmail.CC;
mail.Subject = ActEmail.Subject;
mail.Body = ActEmail.Body;
mail.Importance = Outlook.OlImportance.olImportanceNormal;
if(ActEmail.Attachments.Count != 0)
{
foreach (Attachment item in ActEmail.Attachments)
{
mail.Attachments.Add(item.Attachment1, Outlook.OlAttachmentType.olByValue, 1, item.Attachment1);//.Substring(item.Attachment1.LastIndexOf('\') + 1));
}
}
((Outlook._MailItem)mail).Send();
string theString = mail.CreationTime + mail.SenderEmailAddress;
MailItem.EntryID
is volatile and cannot be trusted. – Dan Wilson