bartekd Posted November 18, 2009 Posted November 18, 2009 I want to automate an email that comes in frequently. I have everything setup, but what I can't figure out is how to make the email send in plain text. the below will send the email in Rich text, but I need it in plain text (looks more professional with the format of my email, and is half the size) This is what I have CreateMailItem() Func CreateMailItem() Local $olMailItem = 0 Local $olFormatrichText = 3 Local $olImportanceLow = 0 Local $olImportanceNormal= 1 Local $olImportanceHigh = 2 $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem($olMailItem) With $oOMail .To = ("Email@Email.com") .Subject = "Subject " ; subject from the email - can be anything you want it to be ; .BodyFormat = $olFormatrichText .Importance = $olFormatrichText;$olImportanceHigh .Body = "Test 1st line" & @CRLF & "Test 2nd line" .attachments.add ("c:\Test1.txt" ) .attachments.add ("c:\test2.txt") .Display .Send EndWith EndFunc
Juvigy Posted November 18, 2009 Posted November 18, 2009 Constant Value olFormatHTML 2 olFormatPlain 1 olFormatRichText 3 olFormatUnspecified 0 Just replace olFormatRichText with olFormatPlain
Zedna Posted November 18, 2009 Posted November 18, 2009 (edited) Instead ofWith $oOMail .Body = "Test 1st line" & @CRLF & "Test 2nd line"UseWith $oOMail .TextBody = "Test 1st line" & @CRLF & "Test 2nd line"EDIT: Sorry I reread your question, my solution is only for CDO.Message not for OutlookConsider using CDO.Message object instead of Outlook.There is nice UDF wrapper for this: Smtp Mailer from Joshttp://www.autoitscript.com/forum/index....x.php?showtopic=23860&hl=CDOMessage&st=0 Edited November 18, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
bartekd Posted November 18, 2009 Author Posted November 18, 2009 the formatplain doesn't work, it gives me this (17) : ==> The requested action with this object has failed.: .BodyFormat = $olFormatplain .BodyFormat = $olFormatplain^ ERROR Is there an include that I need to include in this script? I can't get it to work.
Juvigy Posted November 18, 2009 Posted November 18, 2009 Do you have : Local $olFormatPlain=1 In your script?
water Posted November 18, 2009 Posted November 18, 2009 Maybe the Outlook UDF can help. Function _OutlookSendMail() should do what you want or at least give you some inspiration. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Juvigy Posted November 18, 2009 Posted November 18, 2009 I think it is clear for everyone ? .BodyFormat can have 4 values: Constant Value olFormatHTML 2 olFormatPlain 1 olFormatRichText 3 olFormatUnspecified 0 Just change accordingly as needed. You have to put .BodyFormat=1 for plaintext and .BodyFormat=3 for rich text.
bartekd Posted November 18, 2009 Author Posted November 18, 2009 Thanks but I can't get it to work This is my script CreateMailItem() Func CreateMailItem() Local $olFormatHTML = 2 Local $olFormatPlain = 1 Local $olFormatRichText = 3 Local $olFormatUnspecified = 0 Local $olMailItem = 0 ;Local $olFormatPlain = 3 ;Local $olFormatPlain=1 ;Local $olImportanceLow = 0 ;Local $olImportanceNormal= 1 ;Local $olImportanceHigh = 2; $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem($olMailItem) With $oOMail .To = ("bla@bla.com") .Subject = "Subject " ; subject from the email - can be anything you want it to be .BodyFormat = 1 .Body = "ALLBUDD" & @CRLF & ""; .attachments.add ("c:\1.txt") .Display .Send EndWith EndFunc
Juvigy Posted November 18, 2009 Posted November 18, 2009 And what exactly is not working? Your script works on my PC
water Posted November 18, 2009 Posted November 18, 2009 Works on my PC (Windows XP, Outlook 2002, Autoit 3.3.0.0) as well My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
bartekd Posted November 18, 2009 Author Posted November 18, 2009 (edited) I get this error (25) : ==> The requested action with this object has failed.: .BodyFormat = $olFormatPlain .BodyFormat = $olFormatPlain^ ERROR I have office 2000. Edited November 18, 2009 by bartekd
bartekd Posted November 18, 2009 Author Posted November 18, 2009 do I need to include some other file, or can someone test this that has office 2k?
Juvigy Posted November 19, 2009 Posted November 19, 2009 change .BodyFormat = $olFormatPlain to .BodyFormat = 1
bartekd Posted November 19, 2009 Author Posted November 19, 2009 then I get the same error type. ==> The requested action with this object has failed.: .BodyFormat = 1 .BodyFormat = 1^ ERROR
Juvigy Posted November 19, 2009 Posted November 19, 2009 It works for me. Seems outlook 2000 doesnt have all the properties and methods (or they are changed). Try removing .BodyFormat and leave only .Body = "ALLBUDD" & @CRLF & ""; How does it work now?
bartekd Posted November 19, 2009 Author Posted November 19, 2009 I tried that, and it sends the email, but it is in rich text.
Juvigy Posted November 19, 2009 Posted November 19, 2009 "If there is a particular person in your contacts list that would rather you didn't mail him/her HTML or enhanced e-mail you can set them to receive only plain text e-mail.Click on CONTACTS and then click on the appropriate name in your address book. Just below their e-mail address will be a tag which you can tick to make sure they only get your e-mail in Plain Text." Maybe this is going to work?
bartekd Posted November 19, 2009 Author Posted November 19, 2009 Thanks for thinking outside the box. But this won't work for me becuse I send this email to the same people I want to send and receive regular emails for as well. Any other thoughts?
bartekd Posted December 2, 2009 Author Posted December 2, 2009 can someone that has outlook 2000 installed on their PC try this script out and let me know if it is the same error message?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now