1 Attachment(s)
Outlook signatures created via VB6 won't show images.
I have created a small application, using RobDogg88's example, to create e-mails automatically, when needed.
I have tried without success to get the correct signature appended.
The signature itself appends OK, but the three images don't show up, just leaving a place-holder and the message "This image cannot currently be displayed."
Code:
.HTMLBody = .HTMLBody & "Please contact me, by e-mail or Skype, if you have any difficulties with this.<BR/><BR/>"
.HTMLBody = .HTMLBody & "</p>"
.HTMLBody = .HTMLBody & "</pre>"
Sig_Dir = Environ("APPDATA") & "\Microsoft\Signatures\"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextStream = oFSO.OpenTextFile(Sig_Dir & "New_Teqhou.htm")
Signature = oTextStream.ReadAll
.HTMLBody = .HTMLBody & Signature
.Importance = olImportanceHigh
.ReadReceiptRequested = False
.Display 'Show the email message and allow for editing before sending
This is what the result shows as:
Attachment 125891
I also tried reading the signature and editing it to add full paths for the relevant images, but no difference:
Code:
Private Function ReadSignature(sigName As String) As String
Sig_Dir = Environ("APPDATA") & "\Microsoft\Signatures\"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextStream = oFSO.OpenTextFile(Sig_Dir & sigName)
Signature = oTextStream.ReadAll
HTM_Dir = Replace(sigName, ".htm", "_files\")
Signature = Replace(Signature, sigName, Sig_Dir & HTM_Dir)
Signature = Replace(Signature, "Teqhou_logo.jpg", Sig_Dir & "/Teqhou_logo.jpg")
Signature = Replace(Signature, "MS_Partners.jpg", Sig_Dir & "/MS_Partners.jpg")
Signature = Replace(Signature, "MS_Dynamics.jpg", Sig_Dir & "/MS_Dynamics.jpg")
Signature = Replace(Signature, "New_Teqhou_Files/image002.png", Sig_Dir & HTM_Dir & "/image002.png")
Signature = Replace(Signature, "New_Teqhou_Files/image003.png", Sig_Dir & HTM_Dir & "/image003.png")
Signature = Replace(Signature, "New_Teqhou_Files/image004.png", Sig_Dir & HTM_Dir & "/image004.png")
Dim temphtm As Integer
temphtm = FreeFile
Open Sig_Dir & "Test.htm" For Output As temphtm
Print #temphtm, Signature
Close temphtm
ReadSignature = Signature
End Function
I've tried saving "signature" as a separate .htm file , but that confuses me more! If I double-click that file, the e-mail opens with all images intact!
Anyone have any idea where I'm going wrong?
Re: Outlook signatures created via VB6 won't show images.
The actual image has to be embedded in the HTMLbody and should not be a reference.
Have a look at this page for a sample:
http://www.rondebruin.nl/win/s1/outlook/signature.htm
Re: Outlook signatures created via VB6 won't show images.
Quote:
Originally Posted by
Arnoutdv
Thanks, I tried that, but no change!
Here's my updated code:
Code:
Dim strbody As String
Dim SigString As String
Dim Signature As String
SigString = Environ("appdata") & "\Microsoft\Signatures\New_Teqhou.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
'"About 20 lines of code that build the body text for the message are here, starting:
strbody = "<font face=Verdana> Dear " & oUser.FirstName & ",</font><BR/><BR/>"
strbody = strbody & "Your AD password, which controls access to Teqhou servers, e-mail, etc., runs for a maximum of <font color=red>" & dblMaxPwdDays & " days.</font><BR/><BR/>"
etc.
strbody = strbody & "Please contact me, by e-mail or Skype, if you have any difficulties with this.<BR/><BR/>"
strbody = strbody & "</p>"
strbody = strbody & "</pre>"
Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
.BodyFormat = olFormatHTML
.Recipients.Add (oUser.get("mail"))
.Subject = "Network Password Expiration Notice"
.HTMLBody = strbody & "<br>" & Signature
.Importance = olImportanceHigh
.ReadReceiptRequested = False
.Display 'Show the email message and allow for editing before sending
End With
Set oEmail = Nothing
End If
Set whenpasswordexpires = Nothing
Set oApp = Nothing
next_rs:
rs.MoveNext
Wend
Set oUser = Nothing
Close #logfile
ret = MsgBox("All Done!", vbOKOnly, "Passwords Check")
End
End Sub
Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Is there some odd access rights error here, as I'm running from a completely different location to where Outlook runs!
Re: Outlook signatures created via VB6 won't show images.
Quote:
as I'm running from a completely different location to where Outlook runs!
is the full path to the image file relative to outlook, or is it a network path from outlook
1 Attachment(s)
Re: Outlook signatures created via VB6 won't show images.
Quote:
Originally Posted by
westconn1
is the full path to the image file relative to outlook, or is it a network path from outlook
Hi,
I've tried both!
Initial attempts left the path in the .htm file as it was, i.e. local to Outlook.
Subsequently, I tried changing the path to the full local path, e.g.
C:\Users\<my name>\AppData\Roaming\Microsoft\Signatures\New_Teqhou_files\image001.png
Both had the same result:
Attachment 125913
There should be icons for Facebook and LinkedIn showing to the right of the www.teqhou.com line, (you can see their place-markers), plus three jpegs beneath for my company logo, MS Partners, and MS Dynamics.
If it makes any difference, I'm running Office 2013 on Windows 8.1
Re: Outlook signatures created via VB6 won't show images.
Maybe this discussion on StackOverflow can help you further:
http://stackoverflow.com/questions/8...ure-in-outlook
Re: Outlook signatures created via VB6 won't show images.
Quote:
Originally Posted by
Arnoutdv
Many thanks for that link. That sorted it for me!
Dead simple, really! I just had to add a .Getinspector line to make Outlook create a blank message with the default signature, locate the beginning of the signature block, which follows immediately after "<div class=WordSection1>", then insert my constructed message text into the standard e-mail that had just been created:
Code:
strBody = strBody & "Please contact me, by e-mail or Skype, if you have any difficulties with this.<BR/>"
strBody = strBody & "</p></pre>" 'last line of constructed message
With oEmail
.BodyFormat = olFormatHTML
.Recipients.Add (oUser.get("mail"))
.Subject = "Network Password Expiration Notice"
.Importance = olImportanceHigh
.ReadReceiptRequested = False
.GetInspector = ret
.HTMLBody = Replace(oEmail.HTMLBody, "<div class=WordSection1>", "<div class=WordSection1>" & strBody)
.Display 'Show the email message and allow for editing before sending
End With
Set oEmail = Nothing
Thanks for all your help. I'm now feeling really pleased with myself!:)