Results 1 to 10 of 10
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365

    Adding Image To Email Body

    Hi Guy's I am trying to add images to an email body, i am using the following code, the sigFile (Email Signature) does go onto email body, but trying to add images by similar method but doesn't embed to body ?



    I haven't pasted the full code as there is lots to remove on here

    SigFile, SigPath, mySubj, imgPath, imgFile, eDisc (Email Disclaimer) and eDisc2 (Email Disclaimer) are all strings

    SigFile does go onto email body, just can't get the imgFile to !!!!!!!

    Code:
    MailTo = Me.txtEmailAddress
    SigFile = "Email Signature.jpg"
    SigPath = "//T:/"
    mySubj = Me.txtMake & " Confirmation"
    imgPath = "//T:/Enquiry Pics/"
        If Left(Me.txtMake, 4) = "Stan" Then
            If Left(Me.txtBrand, 4) = "Curv" Then
            img1 = "Stan Curve1.jpg"
            img2 = "Stan Curve2.jpg"
            img3 = "Stan Curve3.jpg"
            img4 = "Stan Curve4.jpg"
            a = Me.txtReply
            Set myItem = myApp.CreateItem(olMailItem)
            Set OutAccount = myApp.Session.Accounts.Item(2)
            With myItem
            .To = MailTo
            .Subject = mySubj
            .HTMLBody = Replace(Replace(a, "|", "<br>"), "Make", Me.txtMake) & "<br>" & "<br>" & _
            img1 & "<br>" & _
            "<P><IMG border=0 hspace=0 alt='' src='file:" & imgPath & img1 & "' align=baseline></P>" & "<br>" & "<br>" & _
            "<P><IMG border=0 hspace=0 alt='' src='file:" & SigPath & SigFile & "' align=baseline></P>" & "<br>" & "<br>" & _
            "<FONT color=#0000CD>" & eDisc & "<br>" & "<FONT color =#0000CD>" & eDisc2
            .SendUsingAccount = OutAccount
    
            .Display
            End With
            End If
        End If

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Why are you using forward slashes in file path? Where are these images located?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Hi June7, i don't know to be honest, i think because that is what was in the path without string, so i will change to single \ in the path and test

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Tried changing the 2 x // to 1 x \ and still doesn't attach

    The path to files are correct by opening the folder location and copying the address bar, i always do that now to make sure correct

    The file names are also correct, although removed some of the names on here but again, all spaces, file names are correct

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I have never seen internal paths with forward slashes nor mapped drive with leading slash.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Hi June7, i think i have made myself a muppet, incorrect file name!!!!!!!!!

    Must read what i do more carefully

    Going to test it but schoolboy error spotted

  7. #7
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Dave, those are used in urls in a web browser when the file is local; e.b. file:///C:/Users/Micron/AccessStuff/Links.txt
    They're not for use in file system paths. If those work, you must be opening them with a browser? Not an expert on network stuff but would think the double \\ would be incorrect unless you start with the computer name as when using UNC paths and not the drive letter.
    Anyway, from what I can see there, this

    src='file:" & imgPath is only

    //T:/Enquiry Pics/" I don't see where you concatenated the file name to the path. I'd drop the leading slashes as well.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Quote Originally Posted by DMT Dave View Post
    Hi June7, i think i have made myself a muppet, incorrect file name!!!!!!!!!

    Must read what i do more carefully

    Going to test it but schoolboy error spotted
    I have this nagging feeling that you've been told several times to debug.print your variables. Then again, I could be thinking of someone else.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    I will post the working code, it was totally me being silly, file names were wrong, i will post the example soon as i can so if anyone else needs it, it's there

  10. #10
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    NP. I have a feeling that, as I mentioned, it looks like you forgot to concatenate the rest of the file path.
    I have spent many a wasted hour staring at the same dumb mistake. Sometimes helps to walk away, do something else then come back. You also can't beat outputting your variables for finding errors.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Adding Items To HTML Email Body
    By DMT Dave in forum Access
    Replies: 6
    Last Post: 01-03-2022, 04:15 AM
  2. Adding a linked reply to email body
    By DMT Dave in forum Access
    Replies: 3
    Last Post: 09-16-2021, 12:39 PM
  3. Adding query results to email body
    By Kaye960 in forum Programming
    Replies: 2
    Last Post: 12-14-2015, 10:57 PM
  4. Replies: 3
    Last Post: 05-18-2015, 11:24 AM
  5. send email with attached image in body
    By trevor40 in forum Programming
    Replies: 5
    Last Post: 02-14-2014, 01:17 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
  •  
Other Forums: Microsoft Office Forums