|
-
Oct 17th, 2005, 05:44 AM
#1
Thread Starter
Member
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.
-
Oct 17th, 2005, 10:18 AM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 17th, 2005, 01:55 PM
#3
Re: Sign Mail and Outlook
Outlook VBA question moved to Office Development.
-
Oct 18th, 2005, 03:21 AM
#4
Thread Starter
Member
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:
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
Last edited by RobDog888; Oct 18th, 2005 at 10:09 AM.
Reason: Added [vbcode] tags
-
Oct 18th, 2005, 10:11 AM
#5
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 18th, 2005, 11:29 AM
#6
Thread Starter
Member
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
-
Oct 18th, 2005, 12:00 PM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 19th, 2005, 01:55 AM
#8
Thread Starter
Member
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?????
-
Oct 19th, 2005, 08:15 AM
#9
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 20th, 2005, 01:35 AM
#10
Thread Starter
Member
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 ,
-
Oct 20th, 2005, 09:56 AM
#11
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Nov 3rd, 2005, 02:54 AM
#12
Thread Starter
Member
Re: Sign Mail and Outlook
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
Last edited by RobDog888; Nov 3rd, 2005 at 10:25 AM.
Reason: Added [vbcode] tags
-
Nov 3rd, 2005, 10:53 AM
#13
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|