1

I am using Microsoft Access to send out emails and am trying to insert an image into the email so that there is a signature.

I am aware that for a recipient to see the image they must have access to it, so because the image is on my local hard drive I am trying to embed it into the body of the email.

I have followed the link: How to add an embedded image to an HTML message in Outlook 2010

To have the following code:

Dim MyOutlook As Object
Dim MyMessage As Object
Set MyOutlook = CreateObject("Outlook.Application")
Set MyMessage = MyOutlook.CreateItem(0)

Dim colAttach As Outlook.Attachments
Dim oAttach As Outlook.Attachment

Set colAttach = MyMessage.Attachments
Set oAttach = colAttach.Add("C:\user1\Documents\signature.jpg")

With MyMessage

    Dim Greeting As String
    If Time >= #12:00:00 PM# Then
        Greeting = "Afternoon,"
    Else
        Greeting = "Morning,"
    End If

    .To = strTo
    .Subject = strSubject
    .HTMLBody = "<font face=Arial><p>" & "Good " + Greeting + "</p>"
    .HTMLBody = .HTMLBody + "<p>" & "Please find attached your latest document." & "</p>"
    .HTMLBody = .HTMLBody + "<p>" & "If you have any questions...." & "</p>"
    .HTMLBody = .HTMLBody + "<p>" & "Kind Regards" & "</p>"
    .HTMLBody = .HTMLBody + "<p>" & "..." & "</p></font>"
    .HTMLBody = .HTMLBody + "<IMG alt='' hspace=0 src='cid:signature.jpg' align=baseline border=0>"

    strAttachments = "2"
     If strAttachments <> "" Then
         For i = 0 To intNrAttch - 1
            .Attachments.Add strFiles(i), 1, intPos
         Next i
     End If
    .Send
End With

But for some reason, what happens it'll attach the image to the email but not display it:

StackOverFlow Can someone please help?

It might be worth noting, that I can have pretty much the same code to send out an email with an image from Excel that work's, so I think there's something with Access that is preventing the code from working.

Community
  • 1
  • 1
Ben Smith
  • 809
  • 5
  • 21
  • 46
  • I tested your code and it worked perfectly with Access 2013 and Outlook 2010. Okay, I commented the last part out from strAttachments = "2", and the for loop. Try it with another image. Maybe it is "broken" – asdev Sep 22 '15 at 18:14

1 Answers1

0

I had a similar problem. My "fix" was to include a .Display before the .Send.

JJJ
  • 32,902
  • 20
  • 89
  • 102