Results 1 to 5 of 5

Thread: Picture below default siganture

  1. #1
    VBAX Regular
    Jan 2014

    Picture below default siganture


    I'm stuck with below problem.

    I have a macro that replies to all with attachments. It works like a charm.
    I would like to add a picture below my default signature when I reply to all.

    I can make it work when it's at the end of entire communication or at the beginning of my reply.
    Can You point me in the right direction?

    Picture is located on the sharde drive.

    This is my partial code responible for placing picture

    With xReplyMailItem
    .Subject = "[I] " & Item.Subject
    .HTMLBody = strbody & "<br>" & .HTMLBody
    .Attachments.Add "W:\ABC\0 Archiwum\picture1", olByValue, 0
    .HTMLBody = strbody & "<br></br>" & "<img src=""W:\ABC\0 Archiwum\picture1""width=50>" & .HTMLBody
    End With
    End With
    Picture is placed at the beginning of my reply.

  2. #2
    With xReplyMailItem
        .Subject = "[I] " & Item.Subject
        .Attachments.Add "W:\ABC\0 Archiwum\picture1", olByValue, 0
        .HTMLBody = strbody & "<br></br>" & "<img src=""W:\ABC\0 Archiwum\picture1"" width=50>" & .HTMLBody
    End With

  3. #3
    VBAX Regular
    Jan 2014
    Hello Arnelgp,

    Thank You for quick reply.
    Unfortunatelly it's still placed above default signature.



    I'm wondering how can I place this picture below signature?

    Im replying to all and when I do .HMTLbody is entire previous communication.

    I have no problem with placing the picture under signature when I creat new message.

  4. #4
    can you find out what is the name of your default signature
    if you have found out, replace mySig on the code with your signature name (do not delete the .htm extension):

    also i noticed your picture does not have an extension so i add .png (replace it with the extension you have).

    Dim sig As String
    sig = ReadSignature("Mysig.htm")
    With xReplyMailItem
        .Subject = "[I] " & Item.Subject
        .Attachments.Add "W:\ABC\0 Archiwum\picture1.png", olByValue, 0
        .HTMLBody = strbody & "<br></br>" & "<img src=""W:\ABC\0 Archiwum\picture1.png"" width=50>" & & "<p><br/><br/></p>" & sig
    End With
    Public Function ReadSignature(sigName As String) As String
    ' arnelgp
    ' sigName should include the .htm extension
    Dim appDataDir  As String
    Dim sig         As String
    Dim sigPath     As String
    Dim fileName    As String
    appDataDir = Environ$("APPDATA") & "\Microsoft\Signatures"
    sigPath = appDataDir & "\" & sigName
    With CreateObject("Scripting.FileSystemObject")
        sig = .OpenTextFile(sigPath).ReadAll
    End With
    'With CreateObject("Scripting.FileSystemObject").CreateTextFile(Environ("userprofile") & "\desktop\sig2.txt", True)
    '    .Write sig
    '    .Close
    'End With
    ' fix relative references to images, etc. in sig
    ' by making them absolute paths, OL will find the image
    fileName = Replace$(sigName, ".htm", "_files/")
    sig = Replace$(sig, fileName, appDataDir & "\" & fileName)
    ReadSignature = sig
    End Function

  5. #5
    It would probably be simpler to use the Word message editor e.g as follows. Incidentally using this method, if the image is part of your signature, there would be no need to add it in code.

    Sub MyReply()
    Dim olMsg As MailItem
    Dim olReply As MailItem
    Dim olTemp As MailItem
    Dim olInsp As Inspector
    Dim wdDoc As Object, wdDoc2 As Object
    Dim oRng As Object, oMsgRng As Object
    Dim oBookmark As Object
    Dim strTo As String
    Dim strSubject As String
        On Error GoTo err_Handler
        Set olMsg = ActiveExplorer.Selection.Item(1)
        With olMsg
            Set olInsp = .GetInspector
            Set wdDoc = olInsp.WordEditor
            Set oMsgRng = wdDoc.Range
        End With
        Set olTemp = olMsg.Reply
        strTo = olTemp.Recipients(1).Address
        strSubject = "[I] " & olTemp.Subject
        Set olReply = CreateItem(olMailItem)
        With olReply
            .BodyFormat = olFormatHTML
            .To = strTo
            .Subject = strSubject
            Set olInsp = .GetInspector
            Set wdDoc2 = olInsp.WordEditor
            Set oRng = wdDoc2.Range
            oRng.collapse 0
            oRng.formattedtext = oMsgRng.formattedtext
            Set oBookmark = wdDoc2.Bookmarks("_MailAutoSig")
            Set oRng = oBookmark.Range
            oRng.collapse 0
            oRng.InlineShapes.AddPicture FileName:= _
                                         "W:\ABC\0 Archiwum\picture1.jpg"
            Set oRng = wdDoc2.Range
            oRng.collapse 1
        End With
        olTemp.Close olDiscard
        Set olTemp = Nothing
        Set olMsg = Nothing
        Set olReply = Nothing
        Set wdDoc = Nothing
        Set wdDoc2 = Nothing
        Set oRng = Nothing
        Set oMsgRng = Nothing
        Exit Sub
        GoTo lbl_Exit
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts