Email query - Signatures

scubadiver007

Registered User.
Local time
Today, 11:53
Joined
Nov 30, 2010
Messages
317
I would like to add the signature. I've seen this link on other forums but it no longer works.

http://www.rondebruin.nl/mail/folder3/signature.htm

Then I saw this:

http://stackoverflow.com/questions/8994116/how-to-add-default-signature-in-outlook



Code:
Dim OlApp As Outlook.Application
  Dim ObjMail As Outlook.MailItem

  Dim BodyHtml As String
  Dim DirSig As String
  Dim FileNameHTMSig As String
  Dim Pos1 As Long
  Dim Pos2 As Long
  Dim SigHtm As String

  DirSig = "C:\Users\" & Environ("username") & _
                               "\AppData\Roaming\Microsoft\Signatures"

  FileNameHTMSig = Dir$(DirSig & "\*.htm")

  ' Code to handle there being no htm signature or there being more than one

  SigHtm = [B][COLOR=red]GetBoiler[/COLOR][/B](DirSig & "\" & FileNameHTMSig)
  Pos1 = InStr(1, LCase(SigHtm), "<body")

  ' Code to handle there being no body

  Pos2 = InStr(Pos1, LCase(SigHtm), ">")

  ' Code to handle there being no closing > for the body element

   BodyHtml = "<table border=0 width=""100%"" style=""Color: #0000FF""" & _
         " bgColor=#F0F0F0><tr><td align= ""center"">HTML table</td>" & _
         "</tr></table><br>"
  BodyHtml = Mid(SigHtm, 1, Pos2 + 1) & BodyHtml & Mid(SigHtm, Pos2 + 2)

  Set OlApp = Outlook.Application
  Set ObjMail = OlApp.CreateItem(olMailItem)
  ObjMail.BodyFormat = olFormatHTML
  ObjMail.Subject = "Subject goes here"
  ObjMail.Recipients.Add "my email address"
  ObjMail.Display


There is a guaranteed signature so the above code can be simplified but not sure how.

Also, what is the "getboiler" function?
 
I have got it partially working but the signature has images
 
Which method are you using? The first method (Default signature) is the simplest and easiest way to get it working.. As Ron describes..
Ron said:
This is the easiest way to add the default signature with or without picture to a mail with VBA code. The only problem is that if you want to send the mail directly you see the screen flicker because we must display the mail for a short time before the code send it.
 
In the first method I can't see how the signature is attached or is it the text defined by "strbody"? It isn't clear to me.

Also, I am using a loop.
 
Did you give it a try? Or have you read through the link completely? Signature is simply added when you set the Format of the body to HTML body.. strBody is just the body of the email..
 
I have set it up for HTML but if I comment out the relevant code the signature doesn't appear in the email.

Code:
    'EmailSig = "C:\Users\" & Environ("username") & "\AppData\Roaming\Microsoft\Signatures"
    
    'FileNameHTMSig = Dir$(EmailSig & "\*.htm")
    
    'HtmSig = GetBoiler(EmailSig & "\" & FileNameHTMSig)
 
I included a ".display" line at the beginning of the email section and changed a part of my code to this

Code:
Me!LetterText & .HTMLBody

It seems I have now got it working, thanks.
 

Users who are viewing this thread

Back
Top Bottom