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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate EMail body with long text and many Access fields

Status
Not open for further replies.

MacroScope

Programmer
Jul 17, 2010
286
US
Is there a simple way to populate the body of an EMail that is sent from within Access? I want it to include a considerable amount of text and data drawn from at least 8 different Access form controls.

There is a finite limit to the number of characters that are allowed to be added to the body using the SendObject function, and I have far exceeded that.

Suggestions and ideas appreciated!
 
Install Outlook if you haven't already; check the Outlook library reference in your Access project. The Outlook object model offers way more flexibility/extensibility. A look through the object browser in the VBA IDE and a rigorous search on the FAQs here, and on the 'net will lead you to 1000's of code samples and tutorials.

Gluais faicilleach le cupan làn
 

MacroScope:

Add Outlook libraries to your References and then:

Code:
Dim olApp As New Outlook.Application
Dim olMessage As Outlook.MailItem

Set olMessage = olApp.CreateItem(olMailItem)
olMessage.BodyFormat = olFormatHTML '(or olFormatRTF)
olMessage.Subject = "[i]My Subject Line[/i]"
olmessage.Recipients.Add "[i]email@cyberspace.net[/i]"
olMessage.Attachments.Add "[i]myfile.ext[/i]"
olMessage.Body = "[i]My Text first line"[/i] & vbCrLf
olMessage.Body = olBody & "[i]My Text second line"[/i] & vbCrLf
olMessage.Show ' Displays on your screen for you to send or use .Send to send it
Set olMessage = Nothing
Set olApp = Nothing

That should get you started. There are ways to format the body text, add cc and bcc, delay the send until a certain time, and set a lot of other properties.
 
Thanks for your help! I think that'll take care of it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top