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

EXCEL TO OUTLOOK - PUTTING DATA ON A SECOND LINE 1

Status
Not open for further replies.

msstrang

Programmer
Sep 19, 2005
62
US
i'm writing a program that takes data from fields in an excel spreadsheet and creates an outlook email from this data.
the only problem is i do not know how to put data from one excel cell on the first line of the outlook email, and put data from another excel cell on the second line in the email.
what is the command in vba to go to the next line in an outlook email.
 
Perhaps something like this:
Code:
MyText = Cells(1,1).Text &vbCrLf &Cells(2,1).Text
where MyText is a string variable that you then write to Outlook. The Cells references will obviously need to be edited to reflect your worksheet.

Regards,
Mike
 
yup, instead of creating a string i just put the &vbCrLf command between my two strings in my write commands, and it works like a charm!
thank you very much!
 
I would like to do the same task with excel. Is your Excel VBA code available?
 
no problem, this is fairly easy;
in a new module in excel create a subroutine or function and put this code in it:

'OPENS A NEW EMAIL IN OUTLOOK
Dim olApp As Outlook.Application
Dim NewMail As Outlook.MailItem
Set olApp = Outlook.Application
Set NewMail = olApp.CreateItem(olMailItem)
'EMAIL TEXT
NewMail.Subject = *****YOUR SUBJECT HERE****
NewMail.Body = ****PUT THE BODY OF YOUR EMAIL HERE****
'DISPLAYS EMAIL
NewMail.Display

it's that simple. also make sure under tools references in your vba screen you have all of the microsoft office and microsoft outlook references selected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top