473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Add Text to Email from Macro

I would like to create a button that opens Outlook and puts some text
in the body of the email. I don't need any attachments, just some
text in the body. I've accomplished the ability to create an email
using a macro, but the text I want to add to the body generates an
error that the text is too long. In addition, I would like the text
formatted so it can bold, make larger, italicize, link, etc.

Can I pull in a pre-formatted html file as the text? If so, how?

Is there any way to do this through a macro? If it has to be done
using code, can you provide an example using "Email Code for Dummies"?

Thx!

Jul 28 '08 #1
1 5538
Here is one way to do it.....

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Set o = CreateObject("Outlook.Application")
Set m = o.CreateItem(0)
m.To = Forms![HiddenKey]![HManagerEmail]
' m.cc = for copies

' m.bcc = for blind copies

m.Subject = "Defect Analysis for " & Forms![fieldname]

' m.body = "now is the time" if html not
desired

==================================
m.bodyformat = 2 ' not necessary if no html

m.htmlbody = Chr(13) & Chr(13) & _
"<body><Table><tr><td><bDate: </b></td><td>" & Date
&
"</td></tr>" & _
"<tr><td><b>Manager: </b></td><td>" &
Forms![HiddenKey]![HManager] & "</td></tr>" & _
"<tr><td><b>Name: </b></td><td>" &
Forms![HiddenKey]![HCompany] & "</td></tr>" & _

"<tr><td></td><td></td></tr>" & _
"</Table></body>"
===================================

' m.send ' to send it instead of displaying it.
m.Display

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The key is to load the HTMLBody and set the bodyformat.
Then you need to include any of the HTML formating code values that
you want to use.
Ron
Jul 29 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ron | last post by:
You know how some web pages require text input, well I'm doing this by running a VBA macro out of Excel. The macro opens IE to the desired url and the following lines of code insert the required...
2
by: Tony Williams | last post by:
I have a query called qrylabels that is based on a table tblbospen. I want to run the query from the Switchboard and also export the results from the query to a comma separated text file called...
50
by: Michael Mair | last post by:
Cheerio, I would appreciate opinions on the following: Given the task to read a _complete_ text file into a string: What is the "best" way to do it? Handling the buffer is not the problem...
1
by: ghadley_00 | last post by:
Hi, I have a MS access database table for which I regularly need to import fixed width text data. At present I have to to cut and paste the text data from its source to a text file, save the...
7
by: Ramon Pam | last post by:
I need create a macro for export to only one text file, of 3 TABLES What is the necessary instructions (for create ONLY ONE FINAL text file) ?? Thanks Ramon
4
by: chimambo | last post by:
I have 2 problems: 1. I want to import a single text file into an access table using a Macro. I am however getting an error that I need to put a specification name argument. What does this mean?...
3
by: agarwasa2008 | last post by:
A macro question. I have action:Transfer Text with the following settings: ------------------------------------ Transfer Type: import Fixed Width Specification Name: ?? Table...
8
by: Irene | last post by:
Hi, I have an MS Access Database with 1 Table containing about 2 million records in Unicode (diferent languages). I would like to export the Table to a Text file (CSV, Tab, etc.) Access...
1
by: Spin | last post by:
Hi, I am trying to setup a macro that emails out a spreadsheet when activated. When I activate the macro it stops to give me a decision block if I want to send out the email "Yes", "No" or...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.