RE: Send Mail w/Access via MAPI
- From: YisMan <yisman@xxxxxxx>
- Date: Sun, 29 Apr 2007 03:14:00 -0700
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
- Follow-Ups:
- Re: Send Mail w/Access via MAPI
- From: Dmitry Streblechenko
- Re: Send Mail w/Access via MAPI
- Prev by Date: Re: PR_SUBJECT question
- Next by Date: Re: How to Read mail body using MAPI
- Previous by thread: PR_SUBJECT question
- Next by thread: Re: Send Mail w/Access via MAPI
- Index(es):
Relevant Pages
|