none
Attaching file inline in message body for RTF Outlook email VBA RRS feed

  • Question

  • I am trying to to the following though Excel and VBA:

    1) Open Word doc and copy contents

    2) Paste into new Outlook RTF email body (contents have placeholders for attachments)

    3) Replace placeholders with inline attachment files.

    I can do step 1 and step 2 just fine.

    For step 3:

    I have tried using embedded OLE attachments in the word doc (InlineShapes.AddOLEObject).  This approach works until I send the email and then it appears that the attachments are converted into picture files that the recipient can't open.

    I have tried parsing the email body and attachments.add with position of placeholder (using InStr function) but the result is off in position and I can't get that quite right.


    Any suggestions?

    Thanks!

    Tuesday, July 31, 2012 6:34 PM

All replies

  • Do you absolutely have to use RTF? If I were doing the coding I'd specify using HTML and add the images where I wanted them using HTML code.
     
    In my experience the positioning in RTF is a bit flaky and I've had little luck in trying to position things exactly. Besides, many Outlook setups will automatically convert RTF to HTML when an email is sent over the Internet, and only Outlook and possibly Eudora can understand Outlook's RTF.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "VDude1234" <=?utf-8?B?VkR1ZGUxMjM0?=> wrote in message news:36d96288-d9c1-437d-b29c-bd7e7570dd14...

    I am trying to to the following though Excel and VBA:

    1) Open Word doc and copy contents

    2) Paste into new Outlook RTF email body (contents have placeholders for attachments)

    3) Replace placeholders with inline attachment files.

    I can do step 1 and step 2 just fine.

    For step 3:

    I have tried using embedded OLE attachments in the word doc (InlineShapes.AddOLEObject).  This approach works until I send the email and then it appears that the attachments are converted into picture files that the recipient can't open.

    I have tried parsing the email body and attachments.add with position of placeholder (using InStr function) but the result is off in position and I can't get that quite right.


    Any suggestions?

    Thanks!


    Ken Slovak MVP - Outlook
    Wednesday, August 1, 2012 4:45 PM
    Moderator
  • The only reason I am using RTF is that there is a requirement for inline attachments... I think that RTF is the only way to accomplish that.  The attachments are PDF files (not images).  Do you have any suggestions on the HTML and OLE attachments approach?  With HTML and OLE, I was able to put the attachment in the right spot but it is converted to an image (nothing happens when I click on it) after the email is sent.

    Thanks.

    Wednesday, August 1, 2012 5:36 PM
  • I was assuming that you were trying to position images, which would work correctly in the HTML. For text I'd extract the text from the PDF's. and put it where it was wanted.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "VDude1234" <=?utf-8?B?VkR1ZGUxMjM0?=> wrote in message news:ab020cba-f9ba-441e-bfb0-ab3b903fbfc2...

    The only reason I am using RTF is that there is a requirement for inline attachments... I think that RTF is the only way to accomplish that.  The attachments are PDF files (not images).  Do you have any suggestions on the HTML and OLE attachments approach?  With HTML and OLE, I was able to put the attachment in the right spot but it is converted to an image (nothing happens when I click on it) after the email is sent.

    Thanks.


    Ken Slovak MVP - Outlook
    Wednesday, August 1, 2012 5:52 PM
    Moderator
  • I need to include the file as an inline attachment (not the contents of the file).
    Wednesday, August 1, 2012 5:56 PM
  • The only way of positioning an attachment in an RTF email is with the Position argument to AttachmentAdd() unfortunately. About all I can suggest with those requirements is to play with the positioning.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "VDude1234" <=?utf-8?B?VkR1ZGUxMjM0?=> wrote in message news:dd55bdcb-5a86-483a-8287-e0bf1ea281e5...
    I need to include the file as an inline attachment (not the contents of the file).

    Ken Slovak MVP - Outlook
    Thursday, August 2, 2012 6:27 PM
    Moderator