Conversion of attachments type olEmbeddedItem

  • Thread starter Alhambra Eidos Kiquenet
  • Start date
A

Alhambra Eidos Kiquenet

Hi misters,

I want to access attachments of a mail (MailItem) and if attach type is
olEmbeddedItem , convert it to olMailItem in memory.



Now, I have this code, saving attachment (.msg file) to disk and using
CreateItemFromTemplate.



Another solutions without save to disk the msg file ?



Any help will be very grateful, thanks in advance, greetings, regards



The code here:



foreach (Outlook.Attachment atch in olMail.Attachments)

{

//olByReference The attachment is a shortcut to the location of the original
file.

//olByValue The attachment is a copy of the original file and can be
accessed even if the original file is removed. olEmbeddeditem The attachment
is an Outlook message format file (.msg) and is a copy of the original
message.

//olOLE The attachment is an OLE document.

if (atch.Type ==
Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem)

{

string rutaEmbebido = Path.Combine(rutaAdjuntos, correo + "_" + atch.Index +
"_" + atch.FileName);

atch.SaveAsFile(rutaEmbebido);

Outlook._Application appOutlook = new Outlook.Application();

Outlook.MailItem msg = null;

//msg =
appOutlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
as Outlook.MailItem;

msg = appOutlook.CreateItemFromTemplate(rutaEmbebido,

appOutlook.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderDrafts)) as Outlook.MailItem;

//msg.Display(false);

RellenarAdjuntos(msg, correo, rutaAdjuntos, ref info);

msg.Delete();

File.Delete(rutaEmbebido);

}

else

{

Console.WriteLine("\r\n\t\t TIPO DE ADJUNTO " + atch.Type + "\r\n\r\n");

info.Adjuntos.Add(info.Adjuntos.Count + 1, atch.FileName);

atch.SaveAsFile(Path.Combine(rutaAdjuntos, correo + "_" + atch.Index + "_" +
atch.FileName));

}

}
 

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

Top