PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Conversion of attachments type olEmbeddedItem

 
 
=?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=
Guest
Posts: n/a
 
      21st Sep 2007

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));

}

}


--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion from type 'DBNull' to type 'String' is not valid Cirene Microsoft ASP .NET 2 19th Jun 2008 06:18 AM
Conversion from type 'DBNull' to type 'String' is not valid Chris Microsoft ASP .NET 2 11th May 2006 09:20 AM
conversion from type 'DBNull' to type 'float' is not valid ibiza Microsoft ASP .NET 2 27th Jan 2006 09:57 PM
Open an attachement of type olEmbeddeditem Nuno Microsoft Outlook Program Addins 3 16th Jan 2006 05:09 PM
Conversion from type 'SqlInt32' to type 'Integer' is not valid Greg Burns Microsoft ADO .NET 2 31st Oct 2005 11:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:10 AM.