Results 1 to 7 of 7

Embedding .jpg image to email

  1. #1
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    225

    Embedding .jpg image to email

    Hello,

    I have figured out how to embed an image to an auto generated email using the .HTMLBody property. But I also want to add text to the body of the email. Whenever I add text to the .Body property it doesn't appear. Then I thought about adding some vbNewLine's after the .HTMLBody property and then adding the text. It brings the text right under the image but I cant space it out any further or create more spaces for more text. If anyone could help me out I would appreciate it. I will post my code below:

    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment


    ' Create the Outlook session.
    Set objOutlook = CreateObject("Outlook.Application")
    ' Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    With objOutlookMsg
    ' Add the To recipient(s) to the message. Substitute
    ' your names here.
    Set objOutlookRecip = .Recipients.Add("Recipient Name") '<--Recipient's name or email address


    objOutlookRecip.Type = olTo
    ' Add the CC recipient(s) to the message.
    'Set objOutlookRecip = .Recipients.Add("CC Recipient Name")
    'objOutlookRecip.Type = olCC
    ' Set the Subject, Body, and Importance of the message.
    .Subject = "This is an Automation test with Microsoft Outlook" '<--Subject
    '.Body = "vbNewLine & vbNewLine & vbNewLine" & "NOTE: Some of you have may have been deactivated for 12+ months" & _
    "of non-use. If you have trouble re-setting your password (or receive a database error when trying" & _
    "to sign-in), just FORWARD this email to so we can reactivate your license."
    'Use this to send the Email using the HTML Format
    '.HTMLBody = "<HTML><H2><b>This is HTML Text in the BODY of the email</b></H2></HTML>"
    .HTMLBody = "<HTML><Head></Head><Body><img SRC=\\cvty.com\dfs\Data\PFFS-BSU\Mark\DBs\Ascend\Logo.jpg></Body></HTML>" & vbNewLine & vbNewLine & "NOTE:" & _
    "Some of you have may have been deactivated for 12+ months" & _
    "of non-use. If you have trouble re-setting your password (or receive a database error when trying" & _
    "to sign-in), just FORWARD this email to so we can reactivate your license."

    .Importance = olImportanceHigh 'High importance

    .Display

    End With

    'Cleanup Code
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    Set objOutlookRecip = Nothing
    Set objOutlookAttach = Nothing

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    41,130
    Not sure what you by "cant space it out any further or create more spaces for more text". Use vbNewLine or vbCrLf to make paragraphs.

    Better put space after last word at the end of each line or when the strings concatenate the words will run together.
    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.
    If any suggestion resolves your issue, please use the Thread Tools dropdown above first post and mark as Solved!

    Debug!Debug!Debug! http://www.cpearson.com/excel/debug.htm

  3. #3
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    225
    I have just been trying this code to see if it will work and it is doing the same thing..it goes to the next line but that is it.

    strMessage = "<html><body><span style='background:yellow;mso-highlight:yellow'>" & "NOTE: Some of you have may have been deactivated for 12+ months of non-use. If you have trouble re-setting your password (or receive a database error" & _
    "when trying to sign-in), <u><b>just FORWARD this email</b></u> to <u>yyyyyyyyy.com</u> so we can reactivate your license. " & vbNewLine & vbNewLine & "</body></html>"

    strMessage = strMessage & "<html><body><font color = red><font size = 1>READ THIS EMAIL COMPLETELY (PLUS ATTACHMENTS) BEFORE INSTALLING AND USING BLAH</body></html>"

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    11,342
    Here is a screenshot of what your code is doing on my PC.
    What do you want it to do?
    Click image for larger version. 

Name:	AccessHTML.jpg 
Views:	9 
Size:	26.8 KB 
ID:	29925

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    41,130
    Okay, apparently cannot have HTML formatted text followed by plain strings. So use HTML tags to define paragraphs and line breaks. Review https://www.w3schools.com/html/html_paragraphs.asp

    .HTMLBody = "<html><body><img SRC=\\cvty.com\dfs\Data\PFFS-BSU\Mark\DBs\Ascend\Logo.jpg>" & _
    "<p><span style='background:yellow;mso-highlight:yellow'>NOTE: Some of you have may have been deactivated for 12+ months of non-use. " & _
    "If you have trouble re-setting your password (or receive a database error when trying to sign-in), " & _
    "<u><b>just FORWARD this email</b></u> to <u>yyyyyyyyy.com</u> so we can reactivate your license.<br><br>" & _
    "<font color = red><font size = 1>READ THIS EMAIL COMPLETELY (PLUS ATTACHMENTS) BEFORE INSTALLING AND USING BLAH</p>" & _
    "</body></html>"

    The body and html tags actually aren't needed. Same output without.
    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.
    If any suggestion resolves your issue, please use the Thread Tools dropdown above first post and mark as Solved!

    Debug!Debug!Debug! http://www.cpearson.com/excel/debug.htm

  6. #6
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    225
    Ah I see the <p></p> is working for a new paragraph. Is there anything for a Tab? or Bullet points?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    41,130
    Bullet and other symbols under Symbols category at the W3Schools link. Example:
    Code:
    "& # 8 2 2 6 ;<font color = red><font size = 1> READ THIS EMAIL COMPLETELY (PLUS ATTACHMENTS) BEFORE INSTALLING AND USING BLAH</p>"
    Dang, forum converts the bullet code to the symbol. So remove spaces from the code string in the example.

    Not aware of HTML tab or indent tags, an indent would require CSS code. Use non-breaking space code repeated (again, remove the spaces): & n b s p ;
    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.
    If any suggestion resolves your issue, please use the Thread Tools dropdown above first post and mark as Solved!

    Debug!Debug!Debug! http://www.cpearson.com/excel/debug.htm

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 12-26-2016, 07:57 AM
  2. CDO email (gmail) make an image clickable
    By Gina Maylone in forum Access
    Replies: 5
    Last Post: 08-13-2016, 06:21 AM
  3. Problem with embedding an image from a url
    By crobaseball in forum General Chat
    Replies: 3
    Last Post: 05-26-2015, 10:27 AM
  4. send email with attached image in body
    By trevor40 in forum Programming
    Replies: 5
    Last Post: 02-14-2014, 12:17 AM
  5. Replies: 1
    Last Post: 05-23-2011, 07:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums