UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Embedding Multiple Images In Outlook, Access 2010    
 
   
BigPaul
post Apr 18 2017, 08:34 AM
Post#1



Posts: 29
Joined: 20-November 04
From: Colchester, UK


Hi Guys,

I want a header and footer logo and three images within the text of my email. (This is a simplistic get-it-working code. The final will be customized for each email)

If I uncomment any of the five commented lines the relevant image is displayed and the REST of the text shows.

i.e. I get only one image and whatever remaining text ~ I don't get five images interspersed with text.

The style section does not seem to work either ~ the footer remains in Times New Roman size 12 :-(

Here is what I have so far. Uncomment any of the lines to see the problem. Ideal is to uncomment them all and see 5 images at the receiving end of the email.

Regards Paul

PS Email is Outlook 2010.

CODE
    Const MyPath = "C:\images\"
    Const MyPicture1 = "Picture1.jpg"
    Const mypicture2 = "Picture2.jpg"
    Const mypicture3 = "Picture3.jpg"
    Const mypicture4 = "Picture4.jpg"
    Const mypicture5 = "Picture5.jpg"

    Dim str_head, str_style, str_body, str_body_end, str_text As String

    With CreateObject("Outlook.Application").CreateItem(0)
        .Attachments.Add MyPath & MyPicture1
        .Attachments.Add MyPath & mypicture2
        .Attachments.Add MyPath & mypicture3
        .Attachments.Add MyPath & mypicture4
        .Attachments.Add MyPath & mypicture5

        str_head = "<html> <head> <meta http-equiv='Content-?jpe' content=' text/html; charset=iso-8859-1'>"

        str_style = "<style type='text/CSS'>" & vbCrLf & _
                    "<!--" & vbCrLf & _
                    "body { background-color: palegreen; } " & vbCrLf & _
                    "h1 { margin: 1cm; font—size:14px; font—family: 'Times New Roman'; } " & vbCrLf & _
                    "p.footer {margin: 1cm; font-size: 8px; font—family: 'Calibri'; } " & vbCrLf & _
                    "-->" & vbCrLf & _
                    "</style>"

        str_body = "</head> <body>"

        'str_text = "<img src=cid:" & Replace(MyPicture1, " ", "%20") & " height=60 width=640>"    'Header logo

        str_text = str_text & "<h1>This is header text size 14 Times New Roman</h1>str_text"

        str_text = str_text & "<p>This is body text size 12 Times New Roman</p>"

        'str_text = "<img src=cid:" & Replace(mypicture2, " ", "%20") & " height=240 width=180>"    'In text image

        str_text = str_text & "<p>This is more body text size 12 Times New Roman</p>"

        'str_text = "<img src=cid:" & Replace(mypicture3, " ", "%20") & " height=240 width=180>"    'In text image

        str_text = str_text & "<p>This is more body text size 12 Times New Roman</p>"

        'str_text = "<img src=cid:" & Replace(mypicture4, " ", "%20") & " height=240 width=180>"    'In text image

        str_text = str_text & "<p class 'footer'>This is footer text size 8 Calibri</p>"

        'str_text = "<img src=cid:" & Replace(mypicture5, " ", "%20") & " height=60 width=640>"       'Footer logo

        str_body_end = "</body> </html>"

        .HTMLBody = str_head & str_style & str_body & str_text & str_body_end
        .Display
    End With

This post has been edited by BigPaul: Apr 18 2017, 08:35 AM
Go to the top of the page
 
BigPaul
post Apr 21 2017, 01:52 AM
Post#2



Posts: 29
Joined: 20-November 04
From: Colchester, UK


A schoolboy error, cut and pasted five times!

I am missing str_text & in my str_text = "<img src=cid:"... statements. I am therefore overwriting the str_text variable every time I add the image code to it! The correct syntax is

str_text = str_text & "<img src=cid:" & Replace(mypicture1, " ", "%20") & " height=240 width=180

If anyone has a pointer to fixing the style section which does not seem to work either ~ the footer remains in Times New Roman size 12 :-( then I will have cracked it.

Go to the top of the page
 
JonSmith
post Apr 21 2017, 02:44 AM
Post#3



Posts: 3,063
Joined: 19-October 10



I say abandon this way of coding / thinking. Writing the html for an email with embedded images in VBA is waaaaay more complicated than it ever needs to be.

Write the email in Outlook and save it as an template file (.oft), this file can then be loaded in VBA really easily and then you don't have to do any formatting or anything. Its just there for you already.

JS
Go to the top of the page
 
cheekybuddha
post Apr 21 2017, 07:57 AM
Post#4


UtterAccess VIP
Posts: 8,845
Joined: 6-December 03
From: Telegraph Hill


Similar typo!
CODE
       str_text = str_text & "<p class 'footer'>This is footer text size 8 Calibri</p>"

should be:
CODE
       str_text = str_text & "<p class='footer'>This is footer text size 8 Calibri</p>"

class='footer'

thumbup.gif

d

--------------------


Regards,

David Marten
Go to the top of the page
 
BigPaul
post Apr 21 2017, 05:57 PM
Post#5



Posts: 29
Joined: 20-November 04
From: Colchester, UK


Cheeky Buddha, who stole my "="??? It was there when I started, thank you,

JS, an interesting thought, I'm off for a couple of days but I'Lloyd give it a try when I get back.
This post has been edited by BigPaul: Apr 21 2017, 05:58 PM
Go to the top of the page
 
cheekybuddha
post Apr 21 2017, 08:18 PM
Post#6


UtterAccess VIP
Posts: 8,845
Joined: 6-December 03
From: Telegraph Hill


yw.gif

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    25th April 2017 - 11:21 AM