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
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