RE: Send Mail w/Access via MAPI



Hi Everyone, It's me again.

I'm not receiving any answers so I'm back with some details, if it may help
anyone better understand my problem.

I wrote a vba procedure in MS Access like this:

Sub SendMail(stEMail As String, Optional stRecName As String, Optional
stSubject As String, Optional stBody As String, Optional StAttachPath As
String)
Dim objMessage As Message
Dim objAttach As Attachment
Dim objRecipient As Recipient
Dim msMessage As String
Dim objSession As New MAPI.Session
objSession.Logon '
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = stSubject
objMessage.Text = stBody

If StAttachPath <> "" Then
objAttach.Source = StAttachPath
Set objAttach = objMessage.Attachments.Add
objAttach.Position = Len(msMessage) + 2
objAttach.Name = "Attachment"
objAttach.Type = CdoFileData
End If

objMessage.Update
Set objRecipient = objMessage.Recipients.Add(stEMail)
objMessage.send showDialog:=False
End Sub

This procedure has several problems:

A) If a machine does not have Office Outlook, It won't run. It must have the
CDO.DLL to work. As far as I understand there is a MAPI32.DLL which is
independent of Outlook. I tried to reference it in Access, but I got a messge
"Can't add a reference to the specified file."

B) Every time the code runs I get a dialog asking me to choose a profile,
where the only option is Outlook. My users don't want to choose a profile for
sending emails. My app will be sending out possibly hundreds of emails per
session (monthly). The code has to be smart enough to figure out by itself
which email client to use.

C) Every run of the code gives a security warning from outlook which must be
bypassed efficiently.

So to solve the first 2 problems (A & B), I'm sure I can reference a generic
MAPI session without hardcoding this or that email client. If I'm not
mistaking, I've seen it done in VB .NET. I just don't know how. All the
sample code I've found till now use either Outlook or Outlook Expess
explicitly via automation. How can I avoid limiting my users to one email app
or the other?

Additionally, there's problem C (security warning). I've seen alot written
about it, and I'm not up to it yet. so I won't bother you about it.

Now I just need a way to get the emails out regardless of the email clients.
Thanks for reading my post. I hope I haven't been to lengthy. If I'm in the
wrong group, please let me know.
I will be grateful for any leads.
Thankfully, YisMan


"YisMan" wrote:

Hi everyone.

I believe my question to be a simple one, but I need an answer nontheless.
I've read quite a bit of threads and FAQs, but haven't found a way out yet.

I'm developing in MS Access 2003 with VBA. My clients would like to have
automatic emails sent from within their applications. Some of these clients
use Outlook Express, while some use Office Outlook. Some might also use
Thunderbird or the likes.

My question is: How can I interact with some sort of generic MAPI object and
let windows figure out who is the default email client and use it for sending
the emails?

My email requirements are pretty simple. Just From, To, Subject, Text/HTML
Body and attachments.

I'd be grateful for any leads
--
Thankfully, YisMan
.



Relevant Pages

  • Re: DocOutlook Landkarte Deutschland
    ... Informationen von Smarttools Outlook Weekly vom 11/19/25.02.2004 ... Karten und Routenplanung direkt aus Outlook aufrufen, ... ByVal Inspector As Inspector) Dim cb As CommandBar Dim mnu As ... ByVal lpOperation As String, _ ...
    (microsoft.public.de.outlook)
  • Re: KONTAKTE - KARTE ZUR ADRESSE ANZEIGEN
    ... Karten und Routenplanung direkt aus Outlook aufrufen, ... Wenn Sie einen Kontakt in Outlook anlegen, geben Sie neben dem Namen, der ... ByVal Inspector As Inspector) Dim cb As CommandBar Dim mnu As ... ByVal lpOperation As String, _ ...
    (microsoft.public.de.outlook)
  • RE: How can I create a outlook appointment item from data in a e-m
    ... Dim strHTMLType 'As String ... Try Picture Attachments Wizard for Outlook: ...
    (microsoft.public.outlook.program_vba)
  • RE: How can I create a outlook appointment item from data in a e-m
    ... Dim strHTMLType 'As String ... Try Picture Attachments Wizard for Outlook: ...
    (microsoft.public.outlook.program_vba)
  • Help creating object in excel VBA
    ... Outlook, and using an word.doc as the message body. ... Dim confirm, sent As Boolean ... Dim rowColArrayAs String ... Public Function GetApptRecAs String, ...
    (microsoft.public.excel.programming)