sending a form using outlook with the data in the body of the emai

J

Josh Sharpe

Hello

I'm trying to send the data in a form via email. However everything I try
only sends the data as an attachment. I do not want this, I need to be able
to read the data as it is being send to a pager and attachments do me no
good. Please help, at this point I'm completly lost
 
N

Neil

If I understand your post correctly, you want to send the contents of a form
as a plain text E-mail?

Listed below is a routine that I have used succesfully to do the same thing.
It takes the entries on your form, and builds the E-mail with Outlook, and
waits for you to send it.

The example uses three fields called Name, JobTitle, and Supervisor, once
you see how it works you will be able to adapt it for your own situation.

*****Code Start*****
'Dim Some Variables
Dim Name As String
Dim Job As String
Dim Super As String
Dim Bodytext As String

'Assign the field contents to the variables
Name = Form.Name
Job = Form.JobTitle
Super = Form.Supervisor

'This part builds the body of the E-mail
bodytext = Chr(13) & "Name: " & Name & Chr(13)
bodytext = bodytext + "Job Title: " & Job & Chr(13)
bodytext = bodytext + "Supervisor: " & Super & Chr(13)

'Dim Outlook and its mail item as referencable objects.
Dim objOutlook As Object
Dim objmailItem As Object

'Create the Outlook object
Set objOutlook = CreateObject("Outlook.Application")

'Access a new mail item
Set objmailItem = objOutlook.CreateItem(olmailItem)

With objmailItem
.Subject = "Your Email Subject"
.Body = bodytext
.display 'Use .Send if you want the message sent instead of
displayed
'.cc = "An Email Address"
'.Importance = olImportanceHigh
'.ReadReceiptRequested = True
'.Application.StatusBar = "Sending mail item..."
'.Attachments.Add
End With

*****Code End*****

Hopefully you can see how the code above builds up the E-mail by taking the
contents of the three fields and ading them to the bodytext variable, along
with CHR(13) to force each entry onto a new line. It then opens Outlook, and
sets some properties and adds the bodytext along with a subject. Giving you a
text E-mail all ready to send.

I would suggest you create a button on your form, and paste the code into
the buttons 'On click' event, and you should be all done.

If you have any problems please re-post and I'll se what I can do to help.

Neil
www.nwarwick.co.uk
 
J

Josh Sharpe

Thanks Neil for the code, however I cannot get it to work. Is there any
alternative coding or way to do this? I don't understand why this is so
difficult.
 
A

adsl

Josh Sharpe said:
Thanks Neil for the code, however I cannot get it to work. Is there any
alternative coding or way to do this? I don't understand why this is so
difficult.
 
A

adsl

Josh Sharpe said:
Thanks Neil for the code, however I cannot get it to work. Is there any
alternative coding or way to do this? I don't understand why this is so
difficult.
 
A

adsl

Josh Sharpe said:
Thanks Neil for the code, however I cannot get it to work. Is there any
alternative coding or way to do this? I don't understand why this is so
difficult.
 
Top