SendObject help when emailing

kbrooks

Still learning
Local time
Today, 10:57
Joined
May 15, 2001
Messages
202
I have a database an employee uses to capture physicians' credentialing information. Anyone that needs added to our patient registration system, she emails the information to me so I can enter them. I had some help setting up a button that, when she clicks it, saves the current record and then sends it to me.

Currently it's sending the information in an attached .txt file and I'd really like to just have the information in the body of the email. I've been doing some searches but nothing is exactly like what I'm trying to do, and I don't know VBA enough to change it to my own needs.

This is the code in the OnClick event of the button:

- - - - - - - - - - - - -

Private Sub Command46_Click()
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToRecord , , acLast
DoCmd.SendObject acSendReport, "ToSend", ".txt", "kbrooks@myemail.com", , , "New Physician", "New Physician Attached", False
End Sub

Private Sub Command50_Click()
DoCmd.SendObject acSendReport, "ToSend", ".txt", "kbrooks@myemail.com", , , "New Physician", "New Physician Attached", False
End Sub

- - - - - - - - - - - - -

Also, after clicking the button, it takes a good 30 minutes for me to get the email. Any ideas on why? Our network is generally pretty speedy, and there are no delays with email sent directly from Outlook.

TIA
 
What you need to do is create the text message in code
by referring to the textbox controls on the form. I'm going to guess at the fields, so you'll need to replace the code with your field names.
Like this

Dim strEmailTo as string
Dim strSubject as string
Dim strText as string

strEmail="kbrooks@myemail.com"
strSubject="New Physician"
strText="Name: " & me.PhysicianName & Chr(13) & "Address: " & me.Address

DoCmd.SendObject acSendNoObject,,,strEmail,,,strSubject,strText,false

The Chr(13) will put a line break in the text.
 

Users who are viewing this thread

Back
Top Bottom