Results 1 to 13 of 13

Thread: Sign Mail and Outlook

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    Sign Mail and Outlook

    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.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sign Mail and Outlook

    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?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Sign Mail and Outlook

    Outlook VBA question moved to Office Development.

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    Re: Sign Mail and Outlook

    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:
    1. MAPISession1.DownLoadMail = False
    2. MAPISession1.NewSession = True
    3. MAPISession1.SignOn
    4. With MAPIMessages1
    5.     .SessionID = MAPISession1.SessionID
    6.     'purge des destinataires
    7. If .RecipCount > 0 Then
    8.     .RecipIndex = 0
    9.     While .RecipCount > 0
    10.         .Delete 1
    11.     Wend
    12. End If
    13.  
    14. 'purge des messages
    15. If .MsgCount > 0 Then
    16.     .MsgIndex = 0
    17.     While .MsgCount > 0
    18.     'purge des fichiers attachés au message
    19.     .AttachmentIndex = 0
    20.         While .AttachmentCount > 0
    21.             .Delete 2
    22.         Wend
    23.     .Delete 0
    24.     Wend
    25. End If
    26.  
    27. .MsgIndex = -1
    28. .MsgSubject = asun
    29. .MsgNoteText = "Documents joints" & vbCrLf & " "  
    30. .RecipType = mapToList
    31. .RecipDisplayName = desti ' destination
    32. .RecipAddress = .RecipDisplayName
    33. .AddressResolveUI = True
    34. .ResolveName
    35.  
    36. .AttachmentIndex = cont  ' number files
    37. .AttachmentPosition = cont
    38. .AttachmentType = cont
    39. .AttachmentPathName = AddBackSlash(DirSel.path) & "\" & Item.Text
    40. .AttachmentName = Item.Text
    41.  
    42. .AttachmentPosition = Len(.MsgNoteText) - 1
    43. .AttachmentType = mapData
    44. .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
    Last edited by RobDog888; Oct 18th, 2005 at 10:09 AM. Reason: Added [vbcode] tags

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sign Mail and Outlook

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    Re: Sign Mail and Outlook

    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

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sign Mail and Outlook

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    Re: Sign Mail and Outlook

    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?????

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sign Mail and Outlook

    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?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    Re: Sign Mail and Outlook

    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 ,

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sign Mail and Outlook

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    Re: Sign Mail and Outlook

    I had done something that i like:

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

    VB Code:
    1. Private Sub Command1_Click()
    2.     DigSigValid
    3. End Sub
    4.  
    5.  
    6. Public Sub AddDigSig()
    7.  'Declare the object and data type that will be used.
    8. Dim bAddSig As Boolean
    9. Dim sig As Signature
    10. Debug.Print file_name
    11. Dim m_WordServer As Word.Application
    12.  
    13.    
    14.    'When there is an error, go to Error_Handler for error handling.
    15.    On Error GoTo Error_Handler
    16.    
    17.    'Initialize the Signature object and add a signature to the document.
    18.    'If the document hasn't been saved:
    19.    '#1 user will be asked to save it first before signing.
    20.    '#2 After it's saved user will be asked to select the digital certificate for signing.
    21.    'If the document has already been saved, then user will only be be presented with #2.
    22.      
    23.     Set wordapp = CreateObject("Word.Application")
    24.     wordapp.Documents.Open ("c:\word\hola.doc")
    25.     wordapp.Visible = False
    26.  
    27.    
    28.     Set sig = ActiveDocument.Signatures.Add
    29.    
    30.    
    31.    'Check the validity of the digital certificate used for signing.
    32.    'If it hasn't expired AND not revoked, then set bAddSig to True.
    33.     If sig.IsCertificateExpired = False And _
    34.        sig.IsCertificateRevoked = False Then
    35.            
    36.       bAddSig = True
    37.     Else
    38.       'If it isn't valid, delete the signature on the document.
    39.        sig.Delete
    40.        bAddSig = False
    41.     End If
    42.    
    43.    'Commit the signature. Until the Commit method is executed,
    44.    'none of the changes to the SignatureSet collection are saved.
    45.    ActiveDocument.Signatures.Commit
    46.    
    47.    'Clean up by destroying the sig object now that it isn't needed anymore.
    48.    Set sig = Nothing
    49.    'wordApp.Documents.Close ("c:\word\hola.doc")
    50.    wordapp.Quit
    51.    Set wordapp = Nothing
    52.    
    53.    
    54. Exit Sub
    55.  
    56. Error_Handler:
    57.    bAddSig = False
    58.    MsgBox "Document signing action has been cancelled."
    59.    Set sig = Nothing
    60.    wordapp.Quit
    61.    Set wordapp = Nothing
    62. End Sub
    63. Public Sub DigSigValid()
    64.  
    65.    'Declare the objects and data type that will be used.
    66.    Dim sSigValid As String
    67.    Dim objSignature As Signature
    68.    Dim wordapp As Word.Application
    69.    
    70.  
    71.    'When there is an error, go to Error_Handler for error handling.
    72.   ' On Error GoTo Error_Handler
    73.  
    74.    'Check all of the signatures
    75.    sSigValid = ""
    76.    
    77.    
    78.    Set wordapp = CreateObject("Word.Application")
    79.    wordapp.Documents.Open ("c:\word\hola.doc")
    80.    wordapp.Visible = False
    81.  
    82.    For Each objSignature In ActiveDocument.Signatures
    83.        sSigValid = sSigValid + "Is Signature from: " + objSignature.Signer _
    84.        + " Valid?: " + Str$(objSignature.IsValid) + vbCrLf
    85.    Next objSignature
    86.  
    87.    MsgBox (sSigValid)
    88.  
    89.    'Create a new document.
    90.  '  Set docNew = Documents.Add
    91.    
    92.    'Print on the newly created document the value of sSigValid.
    93.  '  Selection.TypeText (sSigValid)
    94.  
    95.    'Clean up by destroying the docNew object now that it isn't needed anymore.
    96.   ' docNew.Close
    97.   ' Set docNew = Nothing
    98.  
    99.    Set objSignature = Nothing
    100.  '  wordApp.Close
    101.    wordapp.Quit
    102.    Set wordapp = Nothing
    103. Exit Sub
    104.  
    105. Error_Handler:
    106.    MsgBox "An error has occurred while trying to validate the digital signature. Please try running the DigSigValid macro again."
    107.   ' docNew.Close
    108.   ' Set docNew = Nothing
    109.    Set objSignature = Nothing
    110.    wordapp.Quit
    111.    Set wordapp = Nothing
    112. End Sub
    113. Private Sub Command3_Click()
    114. AddDigSig
    115. 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
    Last edited by RobDog888; Nov 3rd, 2005 at 10:25 AM. Reason: Added [vbcode] tags

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sign Mail and Outlook

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width