General discussion

Locked

Send email + attachment from Access 2000

By AJD ·
I want to construct an email from an Access 2000 form.
The email already contains the subject and body from the form, and I want to automatically add an attachment that is listed as a path in one of th form's controls.
Does anyone have some code to do this?
I would appreciate your help!

The code I have so far is:

Private Sub email_Click()
On Error GoTo Err_email_Click

Dim stDocName As String
Dim stSubject As String
Dim stBody As String

stSubject = [Forms]![Patient Registration]![FileNumber]
stBody = [Forms]![Patient Registration]![Firstname] + " " + [Forms]![Patient Registration]![FamilyName] + Chr(10) + "Birth Date: " + [Forms]![Patient Registration]![datetxt] + Chr(10) + "Sex: " + [Forms]![Patient Registration]![Sex] + Chr(10) + "Clinical History:" + Chr(10) + [Forms]![Patient Registration]![ClinicalData] + Chr(10) + Chr(10) + "Best regards," + Chr(10) + [Forms]![Patient Registration]![submitted]

DoCmd.SendObject , , acFormatRTF, "user@our_domain.com", , , stSubject, stBody, True

Exit_email_Click:
Exit Sub

Err_email_Click:
MsgBox Err.Description
Resume Exit_email_Click

End Sub

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Send email + attachment from Access 2000

by Glenda Gable In reply to Send email + attachment f ...

Ok... Check out Microsoft Knowledge Base (I check there first for just about anything). The article that you may want to really look at is: Q153311 Using Automation to send a Microsoft Exchange Message.

The following code is included in the article:

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

(I am not sure if that lined up correctly.. but you get the idea)

This would depend on whatprogram is being used to send the email. Your code doesnt specify. You may need to use an environmental variable to read which program is being used, or if this is work related and everyone uses the same... it's easier.

Hope this helps!
- Glenda

Collapse -

Send email + attachment from Access 2000

by Shanghai Sam In reply to Send email + attachment f ...

Glenda, Thanks for the tip - I actually wanted to send via Outlook rather than Exchange, but you pointed me in the right direction, so you earned the points! (see KB article Q16108.
I have set up my email function successfully, but now I need a modification to send multiple attachments in a single email - Do you have any suggestions? Send to anthony@egolobaldoctor.com.
Thanks again!

Collapse -

Send email + attachment from Access 2000

by AJD In reply to Send email + attachment f ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Forums