• Subject: Decrypt a mail with MailItem of Outlook and Certificates of VerSig
  • Author: jonathan romero
  • Date: 05 Feb 2010
  • References:
Hi,
i have one a problem, i am develop a application who read a mail from
Exchange Server. my application using Primary Interop Assemblies (PIA) for
connect with Exchange Server to simulate a Outlook.
in this moment i can read all mail but when a read a mail with Digital ID
my application send a exeption and do not achieve download he attachment.

i put my code.
if someone can help me
thank you very much beforehand..

Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
Outlook.MAPIFolder inBox =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items inBoxItems = inBox.Items;
Outlook.MailItem newEmail = null;

inBoxItems = inBoxItems.Restrict("[Unread] = true");

try
{

foreach (object collectionItem in inBoxItems)
{
newEmail = collectionItem as Outlook.MailItem;

//In this section the application send a error
//I think in this section should decrypt a mail for download


if (newEmail != null )//&& from ==
"citidirect.onlinebanking@citicorp.com")
{
if(newEmail.Attachments.Count > 0)
{
for (int i = 1; i <= newEmail.Attachments.Count;
i++)
{

newEmail.Attachments[i].SaveAsFile(@"C:\WEBMAIN\" +
newEmail.Attachments[i].FileName);

//inBoxItems.Remove(newEmail.Attachments[i].Index);
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
--------------------------------------------------------------------------------
Jonathan Romero
Especialista .Net

Profesional Microsoft VIP
DCE 3a Estrella
05 Feb 2010Decrypt a mail with MailItem of Outlook and Certificates of VerSig.jonathan romero
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)