Decrypt a mail with MailItem of Outlook and Certificates of VerSig

  • Thread starter Thread starter jonathan romero
  • Start date Start date
J

jonathan romero

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 ==
"(e-mail address removed)")
{
if(newEmail.Attachments.Count > 0)
{
for (int i = 1; i <= newEmail.Attachments.Count;
i++)
{

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

//inBoxItems.Remove(newEmail.Attachments.Index);
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());

--------------------------------------------------------------------------------
Jonathan Romero
Especialista .Net

Profesional Microsoft VIP
DCE 3a Estrella
 
Back
Top