m1k2k 10 Posted April 14, 2009 Report Posted April 14, 2009 Hi, hab hier ein VB Script um meine Signature ausm ADIR ins OL zu ziehen, hab nur ein Problem mit der Default Signature, die Signatur die ich via VB Script hinzufüge ins OL ist zwar sichtbar aber leider stellt OL die Signatur nicht als Default ein sondern nimmt eine leere. Woran Liegt das? Meine Signatur heiss "Newsignature" hier ein scriptauszug: ' define signature in outlook 2003 On Error Resume Next strDefaultProfile = oShell.RegRead("HKEY_CURRENT_USER\" & strRegProfiles & "\DefaultProfile") iErrNbr = Err.Number strErrMsg = Err.Description On Error Goto 0 If iErrNbr <> 0 Then ' MsgBox "Kein Outlookprofil gefunden" wscript.quit(1) End If If strDefaultProfile = "" Then ' MsgBox "Leeres Outlookprofil gefunden" wscript.quit(1) End If ' use wmi because it is a binary value On Error Resume Next Set oWMIRegistry = GetObject("Winmgmts:\\.\root\default:StdRegProv") iErrNbr = Err.Number strErrMsg = Err.Description On Error Goto 0 If iErrNbr <> 0 Then Msgbox "WMI-Fehler" & vbLf & "<" & Hex(iErrNbr) & "> <" & strErrMsg & ">",,"Fehler" wscript.quit(1) End If ' create unicode array ReDim arrayData(Len(strFilePrefix)*2 + 1) For i = 1 To Len(strFilePrefix) arrayData(i*2 - 2)="&H" & hex(asc(Mid(strFilePrefix,i,1))) arrayData(i*2 - 1)="&H00" Next arrayData(Len(strFilePrefix)*2)="&H00" arrayData(Len(strFilePrefix)*2 + 1)="&H00" ' set unicode array On Error Resume Next oWMIRegistry.SetBinaryValue HKCU, strRegProfiles & "\" & strDefaultProfile & "\9375CFF0413111d3B88A00104B2A6676\00000002", "New Signature", arrayData iErrNbr = Err.Number strErrMsg = Err.Description On Error Goto 0 If iErrNbr <> 0 Then Msgbox "WMI-Fehler" & vbLf & "<" & Hex(iErrNbr) & "> <" & strErrMsg & ">",,"Fehler" wscript.quit(1) End If On Error Resume Next oWMIRegistry.SetBinaryValue HKCU, strRegProfiles & "\" & strDefaultProfile & "\9375CFF0413111d3B88A00104B2A6676\00000002", "Reply-Forward Signature", arrayData iErrNbr = Err.Number strErrMsg = Err.Description On Error Goto 0 If iErrNbr <> 0 Then Msgbox "WMI-Fehler" & vbLf & "<" & Hex(iErrNbr) & "> <" & strErrMsg & ">",,"Fehler" wscript.quit(1) End If ' set unicode array On Error Resume Next oWMIRegistry.SetBinaryValue HKCU, strRegProfiles & "\" & strDefaultProfile & "\9375CFF0413111d3B88A00104B2A6676\00000001", "New Signature", arrayData iErrNbr = Err.Number strErrMsg = Err.Description On Error Goto 0 If iErrNbr <> 0 Then Msgbox "WMI-Fehler" & vbLf & "<" & Hex(iErrNbr) & "> <" & strErrMsg & ">",,"Fehler" wscript.quit(1) End If On Error Resume Next oWMIRegistry.SetBinaryValue HKCU, strRegProfiles & "\" & strDefaultProfile & "\9375CFF0413111d3B88A00104B2A6676\00000001", "Reply-Forward Signature", arrayData iErrNbr = Err.Number strErrMsg = Err.Description On Error Goto 0 If iErrNbr <> 0 Then Msgbox "WMI-Fehler" & vbLf & "<" & Hex(iErrNbr) & "> <" & strErrMsg & ">",,"Fehler" wscript.quit(1) End If wscript.quit(0) Quote
Cybquest 36 Posted April 14, 2009 Report Posted April 14, 2009 Hallo, was steht denn hinterher in der Registry drin? Hast Du mal den Wert von z.B. 9375CFF0413111d3B88A00104B2A6676\00000001\New Signature verglichen, wenn's einmal per Script und einmal von Hand geändert wurde? Möglicherweise ist die Unicode-Umwandlung inkorrekt... (Hab grad keine Zeit zum testen ;) ) PS: Code bitte in Zukunft mit den Code-Tags (#) einfügen. Quote
NilsK 2,971 Posted April 14, 2009 Report Posted April 14, 2009 Moin, vielleicht geht's damit noch besser: zerbit > OutlookSignature Gruß, Nils Quote
m1k2k 10 Posted April 15, 2009 Author Report Posted April 15, 2009 Hallo, was steht denn hinterher in der Registry drin? Hast Du mal den Wert von z.B. 9375CFF0413111d3B88A00104B2A6676\00000001\New Signature verglichen, wenn's einmal per Script und einmal von Hand geändert wurde? Möglicherweise ist die Unicode-Umwandlung inkorrekt... (Hab grad keine Zeit zum testen ;) ) PS: Code bitte in Zukunft mit den Code-Tags (#) einfügen. Hi, Danke für den Hinweis, könntest du das noch mal genauer erklären, woher genau bekomme ich die richtigen Unicodes, wo finde ich diese? Gehe stark davon aus dass der Wert nicht stimmt da ich ja ein bestehendes Script abgeändert habe. Danke für Hilfe Quote
Cybquest 36 Posted April 15, 2009 Report Posted April 15, 2009 Hier mal ein Auszug aus einem VB-Programm, bei dem es bei mir zumindest funktioniert: Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long Const REG_BINARY = 3 Const HKCU = &H80000001 Const REGWMSS_PATH = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem" lngdummy = RegOpenKey(HKCU, REGWMSS_PATH & "\Profiles\default\9375CFF0413111d3B88A00104B2A6676\00000001", lkey) skey = "New Signature" sdata = "MySig" 'Signaturdateiname ohne Extension Dim b() As Byte Dim i As Integer, lArrSize As Long ReDim b(0 To (Len(sdata) - 1) * 2 + 3) For i = 0 To (Len(sdata) - 1) * 2 Step 2 b(i) = Asc(Mid(sdata, i / 2 + 1, 1)) b(i + 1) = 0 Next i b(i + 1) = 0 lArrSize = UBound(b()) + 1 lngdummy = RegSetValueEx(lkey, skey, 0&, REG_BINARY, b(0), lArrSize) lngdummy = RegCloseKey(HKCU) ...vielleicht kannst ja was damit anfangen. Grüße, Frank Quote
m1k2k 10 Posted April 15, 2009 Author Report Posted April 15, 2009 Super, danke für die Tips! Jetzt hab ichs musste diesen part noch mit den zwei Registrierungsschlüsseln einsetzen, für OL 2003 war nichts definiert, nur für XP, (siehe Script oben) ' define signature in outlook 2003 On Error Resume Next oShell.RegWrite "HKCU\Software\Microsoft\Office\11.0\Common\MailSettings\NewSignature",strFilePrefix,"REG_EXPAND_SZ" oShell.RegWrite "HKCU\Software\Microsoft\Office\11.0\Common\MailSettings\ReplySignature",strFilePrefix,"REG_EXPAND_SZ" strDefaultProfile = oShell.RegRead("HKEY_CURRENT_USER\ "& strRegProfiles & "\DefaultProfile") iErrNbr = Err.Number Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.