Adding an image to an email being sent through Access 2010 (1 Viewer)

crowegreg

Registered User.
Local time
Today, 03:21
Joined
Feb 28, 2011
Messages
108
I have Access2010 sending out emails for me. Here is the code I'm using

'Text of Body
msg = saluation
msg = msg & Chr$(13) & Chr$(13) & "Thank you for giving Safe Car Auto Transport the opportunity to assist you with your shipping needs!!"
msg = msg & Chr$(13) & Chr$(13) & "Attached is the contract for your transportation needs. Great care has been taken to insure that all information is correct. Please review, and if an error exists or you have a question , PLEASE inform us immediately so we can make the necessary corrections."


Dim objAccount As Outlook.Account
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.mailitem

'Determine the correct account
For Each objAccount In Outlook.Application.Session.Accounts

If objAccount = "Dispatch - Safecarautotransport.com" Then

'Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
'Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
.To = emailaddress
.SendUsingAccount = objAccount
.Subject = "Safe Car Auto Transport Quote"
.Body = msg
.Attachments.Add contractfile
.Send
End With
End If

Next

Set objOutlook = Nothing
Set objAccount = Nothing
Set objOutlookMsg = Nothing

My question is how do I add a logo to this email? Can it be a hyperlink? Thanks in advance!!
 

mtn

Registered User.
Local time
Today, 10:21
Joined
Jun 8, 2009
Messages
54
Two things you need to do:

  1. You must send your email in an html format for the logo to appear on the body of your email
  2. Your logo must be saved on your website. The size of the logo should be smaller than what you have on the link on your post for a perfect and beautiful email. But all that depends on what you want and not a must. Just a suggestion from me.
That said, I have done the following which should work for you perfectly. Let me know if you are having any other issue regarding this. Simply call the function this way:


ContractEmail "guy@yahoo.com", "Guy Marshal"



Code:
Public Function ContractMessage(strCustomerName As String) As String

    Dim strBody As String
    Dim txtLogoURL As String        'this is for your logo
    Dim txtSignatureURL As String        'this is for your signature logo

    txtLogoURL = "http://www.safecarautotransport.com/images/Safecarlogo.gif"
    txtSignatureURL = "https://ssl.gstatic.com/images/logos/google_logo_41.png"        'Replace this with your email signature logo and if you do not require one then comment it out

    strBody = strBody & "<p>"
    strBody = strBody & "<a href=""http://www.safecarautotransport.com/""><img border=""0"" src=" _
              & txtLogoURL & " alt=""Safe Car Auto Transport"" /></a>"
    strBody = strBody & "</p>"

    strBody = strBody & "<font face=""Georgia"">" & "Hello " & "<b>" & strCustomerName & "</b>" & "," & "<br><br>" & _
              "Thank you for giving Safe Car Auto Transport the opportunity to assist you with your shipping needs!!"

    strBody = strBody & "<p>" & _
              "Attached is the contract for your transportation needs. Great care has been taken to insure that all information is correct. " & _
              "Please review, and if an error exists or you have a question, PLEASE inform us immediately so we can make the necessary corrections. " & "<br>"
    strBody = strBody & "</p>"

    strBody = strBody & "For technical information, help and resources about this contract, please visit our website." & "<br><br>"

    strBody = strBody & "Thank you for using Safe Car Auto Transport. " & "<br><br>" & _
              "" & _
              "Sincerely, " & "<br><br>" & _
              "<b>" & "Safe Car Auto Transport, LLC" & "</b><br>" & _
              "PO Box 216, Broomfield, CO 80038" & "<br>" & _
              "+1 720-295-6485" & "<br>"

    'This where your signature logo will appear. Remove or comment it out if you do not need it or do not have one
    strBody = strBody & "<a href=""http://www.safecarautotransport.com/""><img border=""0"" src=" _
              & txtSignatureURL & " alt=""Safe Car Auto Transport"" /></a>"

    'Something similar to sending a mail from blackberry but you can remove it as well. Just to make your email looks good and nothing else.
    strBody = strBody & "<br><br>" & "<b>" & "+" & "</b>" & " Email sent using <a href=""http://www.safecarautotransport.com/"">" _
              & "SafeCar CRM" & "</a><sup><small>TM</small></sup><br><br>" & _
              "</font>" & _
              "</body></html>"

    ContractMessage = strBody

End Function

Public Function ContractEmail(strEmailAddress As String, strCustomerName As String)

    Dim objAccount As Outlook.Account
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem

    'Determine the correct account
    For Each objAccount In Outlook.Application.Session.Accounts

        If objAccount = "Dispatch - Safecarautotransport.com" Then

            'Create the Outlook session.
            Set objOutlook = CreateObject("Outlook.Application")
            'Create the message.
            Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

            With objOutlookMsg
                .To = strEmailAddress
                .SendUsingAccount = objAccount
                .Subject = "Safe Car Auto Transport Quote"
                .HTMLBody = ContractMessage(strCustomerName)   ' I changed this from .body to .HTMLBody I guess this should resolve sending the mail in HTML
                .Attachments.Add contractfile
                '.Send       'Go ahead and send right away
                .Display   'Display/preview it first if you so wish
            End With
        End If

    Next

    Set objOutlook = Nothing
    Set objAccount = Nothing
    Set objOutlookMsg = Nothing
    
End Function
 

crowegreg

Registered User.
Local time
Today, 03:21
Joined
Feb 28, 2011
Messages
108
THANK YOU!!

I'll work on this tonight.
 

crowegreg

Registered User.
Local time
Today, 03:21
Joined
Feb 28, 2011
Messages
108
With a few, slight changes to the text, this worked perfectly.

Thanks for your assistance!
 

mtn

Registered User.
Local time
Today, 10:21
Joined
Jun 8, 2009
Messages
54
Good luck with your project.
 

durin

New member
Local time
Today, 17:21
Joined
Sep 21, 2013
Messages
6
Hi mtn

You obviously know a bit about sending images in emails perhaps you can help me out with my problem ?

Unfortunately I am not able to post links yet so I can't give you the link to my thread but it is titled

Access Email with Embedded Image Using Outlook


thanks heaps
 

Users who are viewing this thread

Top Bottom