Set Default Signature in Outlook 2007

  • Thread starter Thread starter JK
  • Start date Start date
J

JK

Hi
I try to set default signature through code (C# & VS 2008), it successfully
writes 'New Signature' and 'Reply/Forward Signature' values in a registry.
When I open New mail or reply to any email, my signature does not appear.
I have to restart outlook everytime after setting Default Signature.
Is there any way that I can see my signature in New Email without restarting
the outlook?
Please help me out!!
JK
 
I believe that should be "Reply-Forward Signature", not "Reply/Forward
Signature".

You wrote those values in Unicode to the REG_BINARY values to the correct
places in the profile registry keys?

Do the signatures work the next time Outlook is started and after that or
are you saying that the values are being changed after you set them?

Outlook only reads those values as far as I know when it starts up.
 
Thanks for your reply Ken.
You are right, it should be 'Reply-Forward Signature'. I just misspelled it
in the post.
When I set values for the registry in my code, it changes in the registry..
but the problem is that Outlook reads the values from the registry only on
startup.
I restarted the Outlook thru code..it worked fine but its annoying for the
user.
I dont want to restart Outlook.
 
You are out of luck. Outlook will only read those values from the registry
when it starts up. Why not just write the registry values you want during
installation of your code? That way Outlook has the values when it starts
up.
 
When user set a signature to default, that time I have to write values to
registry..not during installation. I wonder how it happens when we set a
default signature from Outlook, you open new email..u find the signature.
Microsoft doing the same functionality itself but not letting people to do it
.. :-)
 
Outlook caches a lot of data that is read on startup and changed in the UI,
then it may or may not update the registry from the cached information then
or at shutdown. However it doesn't read back registry values after startup.
A lot of configuration information is like that.
 
Thanks Ken. Shall I inform my management that Outlook has to be restarted
after setting Default Signature? or I should look for some work around.
 
Here's a possible workaround, from LIsting 17.8 in my book. It probably works only if Word 2007 is installed, because it uses Word's Application.EmailOptions.EmailSignature.EmailSignatureEntries collection. Code is for VBA and gets information from the GAL to fill out the details of the signature. The juicy EmailSignatureEntries part is near the end.

Dim objOL ' As Outlook.Application
Dim objNS ' As Outlook.NameSpace
Dim blnWeStartedOutlook ' As Boolean
Const olFolderInbox = 6
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
If objOL Is Nothing Then
Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")
objNS.Logon "", "", True, True
' objNS.Logon "Outlook Settings", "", False, True
blnWeStartedOutlook = True
Else
Set objNS = objOL.GetNamespace("MAPI")
objNS.Logon "", "", False, False
End If
If Not objNS.GetDefaultFolder(olFolderInbox) Is Nothing Then
Call CreateSignature(objNS)
Else
MsgBox "Could not start Outlook to set up signature"
End If
If blnWeStartedOutlook Then
objNS.Logoff
objOL.Quit
End If
Set objOL = Nothing
Set objNS = Nothing

Sub CreateSignature(objNS)
Dim objMsg ' As Outlook.MailItem
Dim objDoc ' As Word.Document
Dim objSel ' As Word.Selection
Dim objSig ' As Word.EmailSignature
Dim colSig ' As Word.EmailSignatureEntries
Dim objExUser ' As Outlook.ExchangeUser
Dim objUser ' As Outlook.AddressEntry
Dim strSig ' As String
Dim objInsp ' As Outlook.Inspector
Const olmailitem = 0
Const wdCollapseEnd = 0
Const wdStory = 6
Const olDiscard = 1
Const olMinimized = 1
Set objUser = objNS.CurrentUser.AddressEntry
Set objMsg = objNS.Application.CreateItem(olmailitem)
objMsg.Display
Set objInsp = objMsg.GetInspector
objInsp.WindowState = olMinimized
Set objDoc = objInsp.WordEditor
Set objSel = objDoc.Application.Selection
With objSel
.Move wdStory, -1
.InsertAfter "--" & vbCrLf & Space(3)
.Collapse wdCollapseEnd
.InsertAfter objUser.Name
.Font.Bold = True
.InsertAfter " "
.Collapse wdCollapseEnd
End With
If objUser.AddressEntryUserType = _
olExchangeUserAddressEntry Then
Set objExUser = objUser.GetExchangeUser
If objExUser.Department <> "" Then
strSig = vbCrLf & Space(3) & objExUser.Department
End If
If objExUser.CompanyName <> "" Then
strSig = strSig & vbCrLf & Space(3) & _
objExUser.CompanyName
End If
If objExUser.BusinessTelephoneNumber <> "" Then
strSig = strSig & vbCrLf & Space(3) & _
objExUser.BusinessTelephoneNumber
End If
With objSel
.InsertAfter objExUser.PrimarySmtpAddress
.Font.Bold = False
objDoc.Hyperlinks.Add objSel.Range, _
"mailto:" & objExUser.PrimarySmtpAddress
.Collapse wdCollapseEnd
.InsertAfter strSig
End With
Else
With objSel
.InsertAfter objUser.Address
.Font.Bold = False
objDoc.Hyperlinks.Add objSel.Range, _
"mailto:" & objUser.Address
.Collapse wdCollapseEnd
End With
End If
objSel.InsertAfter vbCrLf
objSel.MoveStart wdStory, -1
objSel.Font.Color = wdColorBlack
Set objSig = _
objDoc.Application.EmailOptions.EmailSignature
Set colSig = objSig.EmailSignatureEntries
colSig.Add objUser.Name, objSel.Range
objSig.NewMessageSignature = objUser.Name
objSig.ReplyMessageSignature = objUser.Name
objInsp.Close olDiscard
Set objMsg = Nothing
Set objDoc = Nothing
Set objSel = Nothing
Set objSig = Nothing
Set colSig = Nothing
Set objExUser = Nothing
Set objUser = Nothing
Set objInsp = nothing
End Sub




--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Ken Slovak - said:
You can look around, but I don't know of any workarounds.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


JK said:
Thanks Ken. Shall I inform my management that Outlook has to be restarted
after setting Default Signature? or I should look for some work around.
 
thank you very much Sue. It worked for me :-)

Sue Mosher said:
Here's a possible workaround, from LIsting 17.8 in my book. It probably works only if Word 2007 is installed, because it uses Word's Application.EmailOptions.EmailSignature.EmailSignatureEntries collection. Code is for VBA and gets information from the GAL to fill out the details of the signature. The juicy EmailSignatureEntries part is near the end.

Dim objOL ' As Outlook.Application
Dim objNS ' As Outlook.NameSpace
Dim blnWeStartedOutlook ' As Boolean
Const olFolderInbox = 6
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
If objOL Is Nothing Then
Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")
objNS.Logon "", "", True, True
' objNS.Logon "Outlook Settings", "", False, True
blnWeStartedOutlook = True
Else
Set objNS = objOL.GetNamespace("MAPI")
objNS.Logon "", "", False, False
End If
If Not objNS.GetDefaultFolder(olFolderInbox) Is Nothing Then
Call CreateSignature(objNS)
Else
MsgBox "Could not start Outlook to set up signature"
End If
If blnWeStartedOutlook Then
objNS.Logoff
objOL.Quit
End If
Set objOL = Nothing
Set objNS = Nothing

Sub CreateSignature(objNS)
Dim objMsg ' As Outlook.MailItem
Dim objDoc ' As Word.Document
Dim objSel ' As Word.Selection
Dim objSig ' As Word.EmailSignature
Dim colSig ' As Word.EmailSignatureEntries
Dim objExUser ' As Outlook.ExchangeUser
Dim objUser ' As Outlook.AddressEntry
Dim strSig ' As String
Dim objInsp ' As Outlook.Inspector
Const olmailitem = 0
Const wdCollapseEnd = 0
Const wdStory = 6
Const olDiscard = 1
Const olMinimized = 1
Set objUser = objNS.CurrentUser.AddressEntry
Set objMsg = objNS.Application.CreateItem(olmailitem)
objMsg.Display
Set objInsp = objMsg.GetInspector
objInsp.WindowState = olMinimized
Set objDoc = objInsp.WordEditor
Set objSel = objDoc.Application.Selection
With objSel
.Move wdStory, -1
.InsertAfter "--" & vbCrLf & Space(3)
.Collapse wdCollapseEnd
.InsertAfter objUser.Name
.Font.Bold = True
.InsertAfter " "
.Collapse wdCollapseEnd
End With
If objUser.AddressEntryUserType = _
olExchangeUserAddressEntry Then
Set objExUser = objUser.GetExchangeUser
If objExUser.Department <> "" Then
strSig = vbCrLf & Space(3) & objExUser.Department
End If
If objExUser.CompanyName <> "" Then
strSig = strSig & vbCrLf & Space(3) & _
objExUser.CompanyName
End If
If objExUser.BusinessTelephoneNumber <> "" Then
strSig = strSig & vbCrLf & Space(3) & _
objExUser.BusinessTelephoneNumber
End If
With objSel
.InsertAfter objExUser.PrimarySmtpAddress
.Font.Bold = False
objDoc.Hyperlinks.Add objSel.Range, _
"mailto:" & objExUser.PrimarySmtpAddress
.Collapse wdCollapseEnd
.InsertAfter strSig
End With
Else
With objSel
.InsertAfter objUser.Address
.Font.Bold = False
objDoc.Hyperlinks.Add objSel.Range, _
"mailto:" & objUser.Address
.Collapse wdCollapseEnd
End With
End If
objSel.InsertAfter vbCrLf
objSel.MoveStart wdStory, -1
objSel.Font.Color = wdColorBlack
Set objSig = _
objDoc.Application.EmailOptions.EmailSignature
Set colSig = objSig.EmailSignatureEntries
colSig.Add objUser.Name, objSel.Range
objSig.NewMessageSignature = objUser.Name
objSig.ReplyMessageSignature = objUser.Name
objInsp.Close olDiscard
Set objMsg = Nothing
Set objDoc = Nothing
Set objSel = Nothing
Set objSig = Nothing
Set colSig = Nothing
Set objExUser = Nothing
Set objUser = Nothing
Set objInsp = nothing
End Sub




--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Pictures in the signature

I have your book, and on page 562, it shows how to insert a picture. Where in the script do I need to add this?

Thanks,

Tim
 
Back
Top