How to embed remote attachments into an Outlook Item

Hi,
   I've learned how to embed attachments into an outlook item (i.e. a contact).
The code is like this:




(...)

// this works and I succeed in getting the contact
Outlook.ContactItem contact =
   Globals.ThisApplication.GetNamespace("MAPI").GetDefaultFolder(
      Outlook.OlDefaultFolders.olFolderContacts).Items.Find(
         string.Format(
            "[ID]='{0}'",
            ID)) as Outlook.ContactItem;

// this works and I succeed in attaching the document to the contact
contact.Attachments.Add(

   @"D:\data\mydocument.pdf", // note this string containing a local path to the document

   Outlook.OlAttachmentType.olByValue,
   System.Type.Missing,
   "doc");


 


Now, I'd like to attach to the contact some remote documents. I've tried putting a URI string instead of the local path string in the previous snippet, but it doesn't work. If I use, instead of Outlook.Attachment, System.Net.Mail.Attachment, trying to construct one from an URI I get the error message "URI are not supported".

 Is there a way to embed an attachment to a contact from a remote URI (a path on a server), possibly without having to download via code the document (and then to destroy the downloaded file, after embedding it in the contact)

thanks,

            Marco


Answer this question

How to embed remote attachments into an Outlook Item

  • Mardo

    Marco,

    I am sorry you had trouble with your Outlook code. In Outlook 2003, the following works:


    Private Sub CreateMailAttach()
    Dim item As mailItem
    Set item = Application.CreateItem(olMailItem)
       item.Attachments.Add ("http://search.msn.com/s/hp/bluesky_logo.gif")
       item.Display
    End Sub

     


    This forum is mainly for Outlook issues that directly pertain to the Visual Studio Tools for Office tools, so you will be better served by posing this question to a forum or newsgroup wholly dedicated to issues such as this one. Here are some resources you should consult for best results:

    microsoft.public.office.developer.vba
    microsoft.public.office.developer.outlook.vba
    microsoft.public.office.developer.outlook.forms

    http://msdn.microsoft.com/office/understanding/outlook
    http://www.outlookcode.com
    http://www.officezealot.com
     
    Best of luck with VSTO and Outlook!

    John.



  • How to embed remote attachments into an Outlook Item