I've some experience in this, so i would like to add something to what EDV Gradl said.
In my application i need to send a massive mailing to some recipients (starting from serialized reports) without any kind of user intervention, and a request is that the email has to be stored in the e-mail client of the sender.
If you use a .net class to send the mail, it will not use the e-mail client (eg. Outlook, that's why you have to specify the e-mail provider in the .net class of send mail) so the user will have no trace of the e-mail sent.
To obtain this, after some days of research, i've come out to use the old vb6 mapi ocx through com interop. It uses the default e-mail client.
After that, i've come into another problem coming from Outlook: when you use Outlook through Simple Mapi (that's what the vb6 mapi ocx does) some security messages appears. While you can turn them off through an option in Outlook Express, in Outlook this option is not present. The problem is that my application is distributed to 200 customers here in Italy, so i have no control on their e-mail clients (so i cannot force anyone to use Outlook Express instead of Outlook). To solve the "Outlook messages problem" i've bought for 100 Euros a product that, in your program, can activate and then deactivate the messages (if you want i can give you in private the name of the product, don't know if i can post the name here).
Now i am able to generate several reports, serialize them (i have a spool manager so i have a table where for each report i store the OutputType (Print or E-Mail) and, in the e-mail case, the recipients names and the desired attachment format (pdf, gif, xps, etc.)) and, from the serialized report, i generate massive mailing through any e-mail client.
This is the code i use to generate a single mail (i've omitted the previous code of exporting because EDV gave you already the answer), i've retouched the code to make it pseudo-code, MSMAPI is the interop to vb6 MSMAPI dll:
Code: Select all
Dim MS As New MSMAPI.MAPISession
If MS.SessionID = 0 Then
MS.DownLoadMail = False
MS.LogonUI = True
MS.SignOn()
End If
Dim MM As New MSMAPI.MAPIMessages
MM.SessionID = MS.SessionID
MM.Compose()
'If you have more than one recipient, don't separate with ";" or "," because Outlook
'doesn't accept this, use RecipIndex
MM.RecipIndex = 0
MM.RecipType = 1 'To
MM.RecipAddress = TheRecipientAddress
'Needed for Outlook, this causes the first Outlook Security message
MM.ResolveName()
MM.MsgSubject = TheEMailSubject
MM.MsgNoteText = TheEMailBody
MM.AttachmentIndex = 0
MM.AttachmentPathName = AttachmentPath
'This causes the second Outlook security message
MM.Send(False)
MS.SignOff()
I've also omitted the deactivation and activation of the Outlook security messages because it uses a third party software.
Let me know if you need any help.
Thanks.