Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting Picture to Email Message (XP)

    I use XL to generate a series of Email messages from a laundry list of Email recipients within the XL file. My challenge is that I would like to insert a picture into the body of the Email message but have run into a road block.

    My XL code goes something like this:

    Sub NewEmailCode()
    Dim objOLook As New Outlook.Application
    Dim objOMail As MailItem
    Dim i As Long

    Set objOLook = New Outlook.Application
    Set objOMail = objOLook.CreateItem(olMailItem)
    oP01a = Trim(CStr(Range("R_FName").Value)) & "," & vbLf & vbLf
    oP01 = Trim(CStr(Range("R_Par01").Value)) & vbLf & vbLf
    oP02 = Trim(CStr(Range("R_Par02").Value)) & vbLf & vbLf
    oP03 = Trim(CStr(Range("R_Par03").Value)) & vbLf & vbLf
    oP04 = Trim(CStr(Range("R_Par04").Value)) & vbLf & vbLf
    oP05 = Trim(CStr(Range("R_Par05").Value)) & vbLf & vbLf

    With objOMail
    .To = "" & Range("R_EAddr") & ""
    .Subject = "This is the subject"
    .Body = oP01a & oP01 & oP02 & oP03 & oP04 & oP05
    'Line of code to insert picture into Email body (a GIF file resides on my desktop)
    End With
    Set objOMail = Nothing
    Set objOLook = Nothing
    End Sub


    I thought a line of code like this would work but it does not: .InlineShapes.AddPicture Filename:= _
    "Eocuments and SettingsjstevenDesktopMyPicture.GIF", LinkToFile:=False, _
    SaveWithDocument:=True


    Any suggestions would be appreciated.
    Thanks,
    John

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting Picture to Email Message (XP)

    Does this site give any information on that:
    http://www.rondebruin.nl
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting Picture to Email Message (XP)

    Jan,

    The site does not address the insertion of a picture object into the Email message.

    Thanks for the reference.
    John

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Inserting Picture to Email Message (XP)

    It's not easy, and only works in HTML formats. See http://www.outlookcode.com/d/code/htmlimg.htm.
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting Picture to Email Message (XP)

    John,

    Using HTML.Body I was able to successfully produce an Email message with a picture inserted after the body of the message.

    Thanks for the link.
    John

  6. #6
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting Picture to Email Message (XP)

    John,

    Although I was able to incorporate the file into the HTMLBody; the recipient of the Email message is not receiving the file image (just a small square box where the image should be). By viewing the source code, the path to the image is displayed ie E:MyPicture.GIF

    Any ideas? I'm not versed well enough with HTML code.

    Thanks,
    John

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Inserting Picture to Email Message (XP)

    Is this also the case when you view your copy of the the same message? It's possible the recipient has a file association problem. I don't use HTML messages or the code I referred you to, so I may not be able to help much.
    -John ... I float in liquid gardens
    UTC -7ąDS

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Inserting Picture to Email Message (XP)

    Hi John,
    Did you follow all the code in the link John provided? It sounds as though you simply included a link to your file in the message, not the actual file itself, which is why your recipient cannot see it.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •