Insert signature from Access 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I have code in my Access db to create an email message using the Outlook
object. I would like the default signature to be inserted at the end of the
email. It is used by multiple people on different PCs (all using windows 2003
terminal server). Each have Outlook set to create a default signature in a
new email but my code seems to ignore this? I am displaying the message
before it is being sent (by manually pressing the send button). Is there a
way to access the default signatures for the individual clients? I have tried
looking on newsgroups and google etc but not found a definitive answer and my
coding skills are only very basic!

The signatures files exist in the c:\documents and settings\user folders -
do I need to find the network logon name and use if statements to add the
file dependant upon who is logged on or is there an easier method? Did try
asking this in the Access newsgroups but was told to ask here...

Thanks in advance for any help.
Sue
 
What method are you using to create the message? Outlook's Application.CreateItem should automatically insert the user's default signature, if they have one.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Hi Sue

I have a default signature but it does not insert it. I am using:

Dim objOutLook As Outlook.Application
Dim objMail As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set db = CurrentDb()

Set objOutLook = New Outlook.Application
Set objMail = objOutLook.CreateItem(olMailItem)

With objMail
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Itinerary")
objOutlookRecip.Type = olTo
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
.Display
.Subject = "Weekly Itinerary"
.Body = "Please find attached the weekly Itinerary for w/c " &
Format(DateAdd("d", 2 - Weekday(Date), _
Date + 7), "dd mmmm yyyy") & vbCrLf & vbCrLf & .To
If Not IsMissing(strFile) Then
.Attachments.Add (strFile)
End If
End With

Thanks
Sue
 
You're overwriting the signature when you set the Body property to new text rather than appending to Body.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Doh - thanks :-)

Sue


Sue Mosher said:
You're overwriting the signature when you set the Body property to new text rather than appending to Body.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Sue, I have some code that does something similar. You might try adapting
this. It depends on everyone having their signature file in Outlook (In
Tools:Options:Mail Format) named "Default Signature". If it is names
something else, change the corresponding line below:

----------------------------------

'The next section inserts the default signature file

Dim objOutlook As Outlook.Application
Dim ObjCtl As Office.CommandBarControl
Dim ObjPop As Office.commandBarPopup
Dim ObjCB As Office.CommandBar
Dim ObjItem As Object

Set objOutlook = CreateObject("Outlook.Application")
Set ObjCB = objOutlook.ActiveInspector.CommandBars("Menu Bar")
Set ObjPop = ObjCB.Controls("Insert")
Set ObjPop = ObjPop.Controls("Signature")
Set ObjCtl = ObjPop.Controls.Item("Default Signature") 'Assumes user's
signature file is named Default Signature
ObjCtl.Execute

Set objOutlook = Nothing
Set ObjCtl = Nothing
Set ObjPop = Nothing
Set ObjCB = Nothing
Set ObjItem = Nothing
 
Note that this technique works only if Word is not the email editor.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Thanks guys...



Sue Mosher said:
Note that this technique works only if Word is not the email editor.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
I've been using John's code but for some reason it sometimes inserts the
wrong signature. I'm wondering if it's the Item("name of signature") that's
causing problems.
 
I've just found a work-around. It's clearly some kind of refresh issue as
occasionally the code works fine but other times merrily moves down the list
of different signatures. In the absence of a refresh/requery method for
CommandBarPopups the Reset method seems to do the job (as long as you're
haven't customised this part of the menu!) - I've inserted it after the line
that sets the popup and before the line that sets the control:
....
Set ObjPop = ObjPop.Controls("Signature")
ObjPop.Reset
Set ObjCtl = ObjPop.Controls.Item("name of signature")
....
 
Hi Sue -

When I append to the body, it reformats my signature. How can I keep the
format of my signature and still append new text to the body??

Thanks!
 
Back
Top