Solved vba inseret signature (with jpeg) (1 Viewer)

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 06:55
Joined
Nov 8, 2005
Messages
3,294

ok the above states that you can edit your html signature to insert a picture .. - i must be doing somthing wrong ...



<xml xmlns:eek:="urn:schemas-microsoft-com:eek:ffice:eek:ffice">
<o:MainFile HRef="../EUTest.htm"/>
<o:File HRef="themedata.thmx"/>
<o:File HRef="colorschememapping.xml"/>
"C:\Users\gpa\AppData\Roaming\Microsoft\Signatures\EUTest_files\image001.jpg" *** does not work ??
<o:File HRef="image002.jpg"/>
<o:File HRef="filelist.xml"/>
</xml>

can someone use a big stick to hit this with .. or point out where I have been stupid ...
lol
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 06:55
Joined
Nov 8, 2005
Messages
3,294
..


this is where it states this .....

In the .htm file in the signatures directory you can edit the htm file. The pictures are stored as relative path and when you use the code it looses that path so if you use discrete path it will be able to find the pictures. so go into the file and look for any relative paths and make them discrete.
"/Microsoft/Signatures/picturefile.jpg"
change that to include the whole path
"/root/user/blah blah../Microsoft/Signatures/picturefile.jpg"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:55
Joined
Oct 29, 2018
Messages
21,468
@GaryPanic. What does "*** does not work ??" mean? Do you see a blank image placeholder on your email? If so, what happens if you right-click on it? What options do you see? If you see an option to "download" the image, what happens if you click on it?
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 06:55
Joined
Nov 8, 2005
Messages
3,294
this image cannot currently be displayed ..
and righthand click - just gives the formating function for a picture - no links etc ..(or downloads)

(sorry for the vagueness )
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 06:55
Joined
Nov 8, 2005
Messages
3,294
Do you see a blank image placeholder on your email? Yes
 

Minty

AWF VIP
Local time
Today, 14:55
Joined
Jul 26, 2013
Messages
10,371
Am I missing a point here?
Why not just edit the signature in outlook and then save it with the image in?
Or are you trying to dynamically change the signature image, in which case why not create the whole signature block as the last part of the email message?
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 06:55
Joined
Nov 8, 2005
Messages
3,294
I might be missing the point myself (LOL)

the edited outlook signature does not add the pictures to the email I get the "this image cannot currently be displayed .."

which is why i was trying to hard code(?) the path to the image to the signature

chances are its me being a little bit dumb ( well quite a lot dumb)!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:55
Joined
Oct 29, 2018
Messages
21,468
Do you see a blank image placeholder on your email? Yes
If you enter the following in your File Explorer or Web Browser, do you see the image?

C:\Users\gpa\AppData\Roaming\Microsoft\Signatures\EUTest_files\image001.jpg
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 06:55
Joined
Nov 8, 2005
Messages
3,294
Its work - but its ok I am data sensitive aware .. and the logo is just a jpeg of a company picture
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:55
Joined
Oct 29, 2018
Messages
21,468
Its work - but its ok I am data sensitive aware .. and the logo is just a jpeg of a company picture
It wasn't that. I was asking because in some work environment, IT implements a group policy where no images will show up in Outlook emails anyway. So, trying this exercise at work where images are not allowed is probably not the best scenario, if it applies to your situation.
 

isladogs

MVP / VIP
Local time
Today, 14:55
Joined
Jan 14, 2017
Messages
18,216
Gary
As already explained, inline images in emails are often blocked due to email security settings.
You can easily test this by sending a test HTML email to yourself from my example CDO Email Tester app .
That includes a PNG image but the chances are you will just see an empty placeholder with a red X
 

Isaac

Lifelong Learner
Local time
Today, 06:55
Joined
Mar 14, 2017
Messages
8,777
Mine often has an option I can click to display images, looks like this:

outlook-not-downloading-images-automatically.png
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 06:55
Joined
Nov 8, 2005
Messages
3,294
park this one to one side while I rethink this
but your responses are awesome ! and thank you
 

Darrell

Registered User.
Local time
Today, 14:55
Joined
Feb 1, 2001
Messages
306
You don't want to replace the whole line with your discrete reference, just the relevant bit within it, so it should still look something like this

<v:imagedata src="C:\Users\UserName\AppData\Roaming\Microsoft\Signatures\Darrell_files\image001.png" o:title="Darrell"/>

See if that helps
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:55
Joined
May 7, 2009
Messages
19,237
this is the Correct way to use your Signature on an Outlook/CDO email.
first create a function that will extract your signature:
Code:
'arnelgp
    Private Function ReadSignature(sigName As String) As String
       'Note:
       'sigName is the name of the htm file
       'example:  "mySignature.htm" (only filename, does not include the Path)
       Dim oFSO, oTextStream, oSig As Object
       Dim appDataDir, sig, sigPath, filename As String
       appDataDir = Environ("APPDATA") & "\Microsoft\Signatures"
       sigPath = appDataDir & "\" & sigName

       Set oFSO = CreateObject("Scripting.FileSystemObject")
       Set oTextStream = oFSO.OpenTextFile(sigPath)
       sig = oTextStream.ReadAll
       ' 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

sample code that calls the function:
Diff:
Dim oApp As Object
Dim oMail As Object
Dim sSignature As String

'retrieve the signature
sSignature = ReadSignature("yourHTMFileHere.htm")

Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
    .To = "someEmailAddressHere"
    .Subject = "Sample signature test"
    .HTMLBody = "Here is your signature" & "<p><BR/><BR/></p>" & sSignature
    .Display
End With
 

Users who are viewing this thread

Top Bottom