vba for outlook signature image (1 Viewer)

Lennie

Registered User.
Local time
Tomorrow, 07:27
Joined
Apr 20, 2017
Messages
11
HI
I currently have a code that will currently attach my signature on outlook together with the image. The issue i'm facing is that the image is specifically reading the image from my username directory. Please see below code under row signImage = "Lennie_files". If another user uses this button it will no longer pick up the image. Is there a generic username i can use in vba or can someone please share what i can put in here to pick up the different usernames? Many thanks for all help given. Part of the code below for reference:

sPath = Environ("appdata") & "\Microsoft\Signatures"
If Dir(sPath, vbDirectory) <> vbNullString Then
sPath = sPath & Dir$(sPath & "*.htm")
Else:
sPath = ""
End If
signImage = "username_files"
completeFolderPath = Environ("appdata") & "\Microsoft\Signatures" & signImage
If Dir(sPath) <> "" Then
StrSignature = GetSignature(sPath)
StrSignature = VBA.Replace(StrSignature, signImage, completeFolderPath)
Else
StrSignature = ""
End If
On Error Resume Next
With NewMail
.To = "lennie email"
.CC = "lennie email"
.Subject = "Test"
' Here at the end of the Email Body
' HTML Signature is inserted.
.htmlBody = EmailBody & "<br><br>" & StrSignature
.display
 

June7

AWF VIP
Local time
Today, 12:27
Joined
Mar 9, 2014
Messages
5,423
Maybe you want Environ("USERNAME"). This will return the Windows login username.
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:27
Joined
Sep 21, 2011
Messages
14,047
I would have thought you would need a generic signature filename to use the code as is?
So if each users file was called AccessSigNature and stored in their respective signature folder, that would work?

The Environ("appdata") already takes into account the username
 

Lennie

Registered User.
Local time
Tomorrow, 07:27
Joined
Apr 20, 2017
Messages
11
thanks for looking at this June7 and Gasman. Tried using both "appdata" and "username" but didn't give me the result i'm after. THANKS guys
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:27
Joined
Sep 21, 2011
Messages
14,047
Really?
Below is what is produced when I try appdate with Environ? I did try it first last night before posting.

? environ("appdata")
C:\Users\Paul\AppData\Roaming
 

Lennie

Registered User.
Local time
Tomorrow, 07:27
Joined
Apr 20, 2017
Messages
11
Hi Gasman you had C:\users\paul\appdata\roaming\. That "Paul" bit is always different. I replaced signImage=environ("appdata") and it does not bring the image on my signature.
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:27
Joined
Sep 21, 2011
Messages
14,047
Hi Gasman you had C:\users\paul\appdata\roaming\. That "Paul" bit is always different. I replaced signImage=environ("appdata") and it does not bring the image on my signature.

That is the idea.
You place the signatures in the signature folder for each user, mine is C:\Users\Paul\AppData\Roaming\Microsoft\Signatures, but the User name will change automatically.

If you want to hold them centrally, then store the path somewhere, or hard code it.

This method does what you were originally asking, it pickls up the user name (and a path). What you do with it after that is up to you.
 

Lennie

Registered User.
Local time
Tomorrow, 07:27
Joined
Apr 20, 2017
Messages
11
i think what i was originally asking is the image associated with the signature. The signature bit for every user comes up with absolutely no issues. The image or the company logo at the bottom of each user signature is the bit thats missing. When the outlook window pops up, the bottom of the signature where the company logo goes displays a message "This image cannot currently be displayed"
Hope the above makes sense
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:27
Joined
Sep 21, 2011
Messages
14,047
i think what i was originally asking is the image associated with the signature. The signature bit for every user comes up with absolutely no issues. The image or the company logo at the bottom of each user signature is the bit thats missing. When the outlook window pops up, the bottom of the signature where the company logo goes displays a message "This image cannot currently be displayed"
Hope the above makes sense

So is the naming convention the same for all users?
IE I could call my signature by the account name (and I do) , so I can have Gmail signature, Yahoo signature etc?

I'd be looking at a users computer on which it does not work, and see what they have there.

I created some email templates yesterday and put the outcmd.dat on a few PCs. I put the templates in a central location for everyone to use and added a Workgroup template path. In the afternoon I got called in as they were not working. Someone on the team had only gone and renamed the folder :)

If you cannot solve this, might be worth just using a common email template on each user's computer? That would already have company logo, text etc?
 

Lennie

Registered User.
Local time
Tomorrow, 07:27
Joined
Apr 20, 2017
Messages
11
Thanks for the suggestion Gasman. i saved the logo and the signature template in a common location and it is now working. Much appreciated for your assistance
 

Users who are viewing this thread

Top Bottom