Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email from Access 2003

Status
Not open for further replies.

jcarmody

Programmer
Apr 25, 2002
39
US
I am attempting to follow the example in FAQ 705-537 to use shellExecute to sent an e-mail with an attachment from my Access 2003 database. This works fine unless I have an attachment. When I have an attachment I get the following message from Outlook: "Cannot start Microsoft Outlook. The command line argument is not valid. Verify the switch you are using." I have suspicians that the Quotes around the attachment is causing Outlook to think I am sending another parameter. I'm interested in ANY way to get the job done, I'm not locked into the ShellExecute method.

The value in stext is
mailto:?Subject=Agent Call Report&Body=See attached&Attach="call.snp"


Here is my code:
If Len(txtMainAddresses) Then
stext = txtMainAddresses
End If
If Len(txtcc) Then
saddedtext = saddedtext & "&CC=" & txtcc
End If
If Len(txtbcc) Then
saddedtext = saddedtext & "&BCC=" & txtbcc
End If
If Len(txtsubject) Then
saddedtext = saddedtext & "&Subject=" & txtsubject
End If
If Len(txtbody) Then
saddedtext = saddedtext & "&Body=" & txtbody
End If
If Len(txtattachment) Then
saddedtext = saddedtext & "&Attach=" & Chr$(34) & txtattachment & Chr$(34)

End If

stext = "mailto:" & stext

If Len(saddedtext) <> 0 Then
Mid$(saddedtext, 1, 1) = "?"
End If

stext = stext & saddedtext

' launch default e-mail program
If Len(stext) Then
Call ShellExecute(hwnd, "open", stext, vbNullString, vbNullString, SW_SHOWNORMAL)
End If
 
I use the CDO library to bounce e-mails directly off the mail server, however this depends on how your mail server has been set up...

if that's not possible, then it might be better to use the default mail application you have and automate it... e.g. you can include the outlook library and just call the methods in that...

--------------------
Procrastinate Now!
 
Thanks for the reply. I ended up doing what you suggested, by including the Outlook library automated sending mail through it. That took care of the attachment problem, but gave me the security message, "A program is trying to access e-mail addresses you have stored in Outlook..." I know form other threads that I have a couple of ways around this one. I've downloaded the click yes product and am testing with it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top