Decrypt a mail with MailItem of Outlook and Certificates of VerSig

  • Thread starter jonathan romero
  • Start date

jonathan romero

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 =
Outlook.Items inBoxItems = inBox.Items;
Outlook.MailItem newEmail = null;

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


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;

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

catch (Exception ex)

Jonathan Romero
Especialista .Net

Profesional Microsoft VIP
DCE 3a Estrella

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question