Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / September 2005

Tip: Looking for answers? Try searching our database.

Need help with VBS code to open Outlook

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick - 13 Sep 2005 22:36 GMT
Hi everyone!!
Quick question on the above code. Can I pass a text file to the body item.
Here is code:
============================
Dim ol, ns, newMail

Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")

Set newMail = ol.CreateItem(olMailItem)

newMail.Subject = "Testing sublect header"
newMail.TO="fakeaddresshere@Test.com"
newMail.Body = "testing body" -> **Here
newMail.DISPLAY
Set ol = Nothing

Could i say something like: newMail.Body=C:\test.txt

Meaning i would like to display in the body of this email the text included
inside that text file.

Can this be done?

Thx for all your help!!!
Eric Legault [MVP - Outlook] - 13 Sep 2005 22:50 GMT
You can with the Microsoft Scripting Library - use the TextStream object from
the FileSystemObject:

Dim objFS, objTS

Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strStationeryFilePath, 1, False)

newMail.Body = objTS.ReadAll
objTS.Close

Signature

Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard - http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/

> Hi everyone!!
> Quick question on the above code. Can I pass a text file to the body item.
[quoted text clipped - 21 lines]
>
> Thx for all your help!!!
Patrick - 14 Sep 2005 20:31 GMT
Thx for the hlp Eric, this works greate.

> You can with the Microsoft Scripting Library - use the TextStream object from
> the FileSystemObject:
[quoted text clipped - 32 lines]
> >
> > Thx for all your help!!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.