HI,
At the moment I can send messages through Outlook and mapi, but i would like to send signed messages like outlook does.
How i can do it?
Thanks for your help.
Printable View
HI,
At the moment I can send messages through Outlook and mapi, but i would like to send signed messages like outlook does.
How i can do it?
Thanks for your help.
You need to display the email message using the Outlook Object Model and execute the Insert Signature menu item.
Are you familiar with the Commandbars collection?
Outlook VBA question moved to Office Development.
Firts ,thanks for your interest, you don't know how dificult is it ,to find an answer about it,
Second, at the moment ,i have got something like it:
VB Code:
MAPISession1.DownLoadMail = False MAPISession1.NewSession = True MAPISession1.SignOn With MAPIMessages1 .SessionID = MAPISession1.SessionID 'purge des destinataires If .RecipCount > 0 Then .RecipIndex = 0 While .RecipCount > 0 .Delete 1 Wend End If 'purge des messages If .MsgCount > 0 Then .MsgIndex = 0 While .MsgCount > 0 'purge des fichiers attachés au message .AttachmentIndex = 0 While .AttachmentCount > 0 .Delete 2 Wend .Delete 0 Wend End If .MsgIndex = -1 .MsgSubject = asun .MsgNoteText = "Documents joints" & vbCrLf & " " .RecipType = mapToList .RecipDisplayName = desti ' destination .RecipAddress = .RecipDisplayName .AddressResolveUI = True .ResolveName .AttachmentIndex = cont ' number files .AttachmentPosition = cont .AttachmentType = cont .AttachmentPathName = AddBackSlash(DirSel.path) & "\" & Item.Text .AttachmentName = Item.Text .AttachmentPosition = Len(.MsgNoteText) - 1 .AttachmentType = mapData .Send False
------- This code is a simple code about my program,
I can send messages thourth outlook Express,and send ok.
Question, the Outlook Object Model also works with Outlook and O. Express?
Thanks again for your help and sorry for my english
The Outlook Object Model is only for the full version of Outlook and not Outlook Express. OE is not programmable. Looks like you using the MSPI control. You will probably have to just append to the body of the message, the signature.
Thanks,
If i do somothing for Outlook, also will be compatible with OE?
how i have to do it? or where i have to read ?
Thanks
No, if you do something for Outlook using the OOM it will NOT be for OE. OE is not programmable. It does not expose any valid COM objects to automate.
Sorry, so ,i have to do 2 codes to send a email ,for example if the user wants to send a email with OE, cand send signed, and if he check the normal Outlook ,can't sent signed?????
Depends on how you want it to work. If you want to give the option to the user to use Outlooks saved signatures then that would be possible using Outlook, but for Express you would have to append something at the end of the body of the email and either have it from a saved file or add a standard default signature. How are you going to give Express users the option?
I have got a simple form, with a textbox, that the user can put the email ,and subject and can put files encrypted or not. Also a button of "accept" ,and sends automatic throught Outlook.
Now it's very important also add a digital sign to send documents ,and i wanted to do it. For what i have read ,i will have to put an option in the menu ,to configure de program to send mails thourtgh Outlook or OE, if the user check OE ,the form ,will enable a option to add a digital sign, if the user check Outlook ,this option will be dissabled. (It's correct?)
Thanks ,
Umm, backwards. Outlook saves its signatures to files in your user profile. You can use this to add the signature when using Outlook. In Outlook Express you can not program against it.
So if using outlook you will have to find the signature file (name varies as the users names them) and insert into the body of the message.
C:\Documents and Settings\UserName\Application Data\Microsoft\Signatures\
Is the Outlook location of the signatures. There will be three files for each signature. Text, htm, and rtf.
I had done something that i like:
----------------
VB Code:
Private Sub Command1_Click() DigSigValid End Sub Public Sub AddDigSig() 'Declare the object and data type that will be used. Dim bAddSig As Boolean Dim sig As Signature Debug.Print file_name Dim m_WordServer As Word.Application 'When there is an error, go to Error_Handler for error handling. On Error GoTo Error_Handler 'Initialize the Signature object and add a signature to the document. 'If the document hasn't been saved: '#1 user will be asked to save it first before signing. '#2 After it's saved user will be asked to select the digital certificate for signing. 'If the document has already been saved, then user will only be be presented with #2. Set wordapp = CreateObject("Word.Application") wordapp.Documents.Open ("c:\word\hola.doc") wordapp.Visible = False Set sig = ActiveDocument.Signatures.Add 'Check the validity of the digital certificate used for signing. 'If it hasn't expired AND not revoked, then set bAddSig to True. If sig.IsCertificateExpired = False And _ sig.IsCertificateRevoked = False Then bAddSig = True Else 'If it isn't valid, delete the signature on the document. sig.Delete bAddSig = False End If 'Commit the signature. Until the Commit method is executed, 'none of the changes to the SignatureSet collection are saved. ActiveDocument.Signatures.Commit 'Clean up by destroying the sig object now that it isn't needed anymore. Set sig = Nothing 'wordApp.Documents.Close ("c:\word\hola.doc") wordapp.Quit Set wordapp = Nothing Exit Sub Error_Handler: bAddSig = False MsgBox "Document signing action has been cancelled." Set sig = Nothing wordapp.Quit Set wordapp = Nothing End Sub Public Sub DigSigValid() 'Declare the objects and data type that will be used. Dim sSigValid As String Dim objSignature As Signature Dim wordapp As Word.Application 'When there is an error, go to Error_Handler for error handling. ' On Error GoTo Error_Handler 'Check all of the signatures sSigValid = "" Set wordapp = CreateObject("Word.Application") wordapp.Documents.Open ("c:\word\hola.doc") wordapp.Visible = False For Each objSignature In ActiveDocument.Signatures sSigValid = sSigValid + "Is Signature from: " + objSignature.Signer _ + " Valid?: " + Str$(objSignature.IsValid) + vbCrLf Next objSignature MsgBox (sSigValid) 'Create a new document. ' Set docNew = Documents.Add 'Print on the newly created document the value of sSigValid. ' Selection.TypeText (sSigValid) 'Clean up by destroying the docNew object now that it isn't needed anymore. ' docNew.Close ' Set docNew = Nothing Set objSignature = Nothing ' wordApp.Close wordapp.Quit Set wordapp = Nothing Exit Sub Error_Handler: MsgBox "An error has occurred while trying to validate the digital signature. Please try running the DigSigValid macro again." ' docNew.Close ' Set docNew = Nothing Set objSignature = Nothing wordapp.Quit Set wordapp = Nothing End Sub Private Sub Command3_Click() AddDigSig End Sub
-----------
With it i can sing a word file AddDigSig() ,and try if it it's valid or not with DigSigValid.
But also i have got a problem ,i can just only check if it's valid once ,at second time i recive a message Error 462 ,the server doesn't exist or it's not present. It's an error from " For Each objSignature In ActiveDocument.Signatures ". Can you help me?
Thanks
You might want to try creating a word document object variable instead of using ActiveDocument. Also, if the user already has word open then you should just use that instance to avoid the issue.