ibeling
asked on
Insert signature to email via visual basic for application
I like to insert a signature (name, telefon, ... not signature like certifcate) in a email via visual basic for application
are you actually writing an e-mail application? or you mean just appending a signature?
if the latter, yes, simply take your message, append the signature, and then pass the new
message to your procedure.
if the latter, yes, simply take your message, append the signature, and then pass the new
message to your procedure.
ASKER
I have already some signature defined in Outlook. (ones for internal use, ones for external, ones for private). So maybe my question should be more "how can i access the signature collection" ...
No. The way outlook inserts a signature is to take the stored signature and code it directly into the html of the email, so the only way you can insert the signature is to do the same. There is no field such as OutlookApp.signature("Name ") or anything like that that you can use.
As for where outlook stores it, all signatures are stored in HTML, Rich Text AND .txt format under
C:\Documents and Settings\[username]\Applic ation Data\Microsoft\Signatures
So if you know the name of the signature. You can concatonate as follows.
Open up C:\Documents and Settings\[username]\Applic ation Data\Microsoft\Signatures\ myName.txt (or .htm or .rtf )
Copy Everything
Paste it into your message.
This can easily be automated, let me know if you can't figure it out.
As for where outlook stores it, all signatures are stored in HTML, Rich Text AND .txt format under
C:\Documents and Settings\[username]\Applic
So if you know the name of the signature. You can concatonate as follows.
Open up C:\Documents and Settings\[username]\Applic
Copy Everything
Paste it into your message.
This can easily be automated, let me know if you can't figure it out.
ASKER
It will help me to save time if you can make a little code snippet, to start.
Thanks
Thanks
Well I have no idea how you're writing you email in Visual basic, but to access that file you say:
dim SIGNATURE As String, text As String, _
SignatureName As String, Username As String
username = 'Fill this in yourself
SignatureName = Name 'Fill this in yourself
Open "C:\Documents and Settings\" & Username & "\Application Data\Microsoft\Signatures\ " & SignatureName & ".txt" For Input As #1
SIGNATURE = vbNullString
Do While Not EOF(1)
Line Input #1, text
SIGNATIRE = SIGNATURE & vbNewLine & text
Loop
Close #1 'Closes the signature file you opened
'At this point you have the entire signature stored as a string (SIGNATURE). Do with it what you will. Attatch it to the end of the message is probably the best thing.
MessageTextBox.text = MessageTextBox.text & vbNewLine & SIGNATURE
'Now send the message, complete with signature and all.
dim SIGNATURE As String, text As String, _
SignatureName As String, Username As String
username = 'Fill this in yourself
SignatureName = Name 'Fill this in yourself
Open "C:\Documents and Settings\" & Username & "\Application Data\Microsoft\Signatures\
SIGNATURE = vbNullString
Do While Not EOF(1)
Line Input #1, text
SIGNATIRE = SIGNATURE & vbNewLine & text
Loop
Close #1 'Closes the signature file you opened
'At this point you have the entire signature stored as a string (SIGNATURE). Do with it what you will. Attatch it to the end of the message is probably the best thing.
MessageTextBox.text = MessageTextBox.text & vbNewLine & SIGNATURE
'Now send the message, complete with signature and all.
If you need outlook code, take a look here:
http://www.outlookcode.com/
http://www.outlookcode.com/
ASKER
We generate Emails from a application.
Depend of the system variable USERNAME, we want add his signature.
Yes it is strange. But the customer wishes are our job.
Thanks for help.
Regards Ingo
Depend of the system variable USERNAME, we want add his signature.
Yes it is strange. But the customer wishes are our job.
Thanks for help.
Regards Ingo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
once taking reccomendations, if a response isn't given, I would like to suggest that I gave a working solution.
Alain
Alain
message As String
signature As String
message = message & vbNewLine & vbNewLine & signature