Add Images in CDO mail message HTMLBody (1 Viewer)

Hello1

Registered User.
Local time
Today, 06:24
Joined
May 17, 2015
Messages
271
Hey guys, again me and my mail troubles :D
Code:
    Dim FileName As String
    Dim emailText As Stringt
    Dim iMsg As Object
    Dim iConf As Object
    Dim strbody As String
    Dim Flds As Variant
    Dim varReturn As Variant
    Dim objImage As Object
    Dim myPic As String

If Not MyRs.EOF Then
                MyRs.MoveFirst
                    While Not MyRs.EOF
                        Set iMsg = CreateObject("CDO.Message")
                        FileName = Format(MyRs!IdCustomer, "000000") & "_" & Left(MyRs!Date, 2) & "_" & Right(MyRs!Date, 2)
                        FilePath = "D:\PDF\" & Right(MyRs!Date, 4) & "year\" & FileName & ".pdf"
                        emailText = emailText & _
                            "<p style= 'margin:0;'>Dear,</p>" & _
                            "<br>" & _
                            "some text " 
                        With iMsg
                            Set .Configuration = iConf
                            .To = MyRs!FirstOfEmail
                            .CC = ""
                            .BCC = ""
                            .From = """MyName or sth"" <email@gmail.com>"
                            .Subject = "Subject text"
                            .HTMLBody = emailText & GetTextFileContents("D:\mylocatin\signature.html") & "<html>Check this out: <img src=""cid:myimg.png""></html>" 
                            Set objImage = iMsg.AddRelatedBodyPart("D:\mylocation\myimg.png", "myimg.png", cdoRefTypeId)
                                objImage.Fields.Item("urn:schemas:mailheader:Content-ID") = "<myimg.png>"
                                objImage.Fields.Update
                            .HTMLBodyPart.Charset = "utf-8"
                            .AddRelatedBodyPart "D:\mylocation\myimg.png", "myimg.png", cdoRefTypeId
                            .AddAttachment FilePath
                            .Send
                        End With
                        Set iMsg = Nothing                  
                        emailText = ""
                MyRs.MoveNext
                    Wend
                DoCmd.Hourglass False
                varReturn = SysCmd(acSysCmdSetStatus, " ")
                MsgBox "E-mails sent.", vbInformation
            End If

I get the image but as attachment, how can I get it as a part of the HTMLBody just like I get it when sending over Outlook?
 

Hello1

Registered User.
Local time
Today, 06:24
Joined
May 17, 2015
Messages
271
Alright, I had to save the image as .gif. Now it shows up in the body.
However, in the gmail app on my phone I see the picture in the body and no attachment whats good but on my laptop browser I see the image in the body but also in the attachment, besides my pdf file. Any way to get rid or hide the attachment?
 

Users who are viewing this thread

Top Bottom