How do I insert Message in new Outlook email using command from A.

G

Guest

I am in Access using visual basic code. I want to open Outlook, open a new
email, insert the email address from an Access record and insert a message
into the email. The code line I have looks like this:
val = Shell("C:\Program Files\Microsoft Office\Office10\outlook.exe /c
ipm.note /m " & stEmail, 1)
This works to open Outlook to a new message and with the email address
inserted where "stEmail" is a variable containing the email address.

QUESTION: How do I insert a message (stMessage) into this email?
 
D

Dirk Goldgar

RustyNail said:
I am in Access using visual basic code. I want to open Outlook, open
a new email, insert the email address from an Access record and
insert a message into the email. The code line I have looks like this:
val = Shell("C:\Program Files\Microsoft
Office\Office10\outlook.exe /c ipm.note /m " & stEmail, 1)
This works to open Outlook to a new message and with the email address
inserted where "stEmail" is a variable containing the email address.

QUESTION: How do I insert a message (stMessage) into this email?

Assuming Outlook is set as your default mail client, can't you just use
SendObject to build and display the e-mail? Something like

DoCmd.SendObject _
To:=strEmail, _
Subject:=strSubject, _
MessageText:=strMessage, _
EditMessage:=True
 
J

John Nurick

For simple email tasks it's usually easiest to use DoCmd.SendObject; you
can use this to send a message without an object attached to it.
 
G

Guest

When I try to use SendObject method suggested in reponse to my original
question, I get a message that says Microsoft Access can't send this message.
Possibly due to security settings on my computer but I can't identify which
ones or if that is the problem for sure. Any ideas?
 
D

Dirk Goldgar

RustyNail said:
When I try to use SendObject method suggested in reponse to my
original question, I get a message that says Microsoft Access can't
send this message. Possibly due to security settings on my computer
but I can't identify which ones or if that is the problem for sure.
Any ideas?

You get that message without any further explanation, and without seeing
any other prompting dialog -- maybe one to confirm that you really want
to send the message? Hmm. You could automate Outlook, I suppose, but
there's no guarantee that whatever is preventing Access from sending the
message won't interfere with that.

What version of Access are you using? If you're using Access 2003,
maybe the macro security setting is interfering. If not, but if you're
running under Windows XP SP2, maybe there's some security setting there
that is doing it.

You'll find a variety of information about sending e-mail from Access on
this web page:

http://www.granite.ab.ca/access/email.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top