Jump to content

Recommended Posts

Posted

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

Posted

Constant Value

olFormatHTML 2

olFormatPlain 1

olFormatRichText 3

olFormatUnspecified 0

Just replace olFormatRichText with olFormatPlain

Posted (edited)

Instead of

With $oOMail
.Body = "Test 1st line" & @CRLF & "Test 2nd line"

Use

With $oOMail
.TextBody = "Test 1st line" & @CRLF & "Test 2nd line"

EDIT: Sorry I reread your question, my solution is only for CDO.Message not for Outlook

Consider using CDO.Message object instead of Outlook.

There is nice UDF wrapper for this: Smtp Mailer from Jos

http://www.autoitscript.com/forum/index....x.php?showtopic=23860&hl=CDOMessage&st=0

Edited by Zedna
Posted

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.

Posted

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

 

Posted

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.

Posted

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

Posted

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

 

Posted (edited)

I get this error

(25) : ==> The requested action with this object has failed.:

.BodyFormat = $olFormatPlain

.BodyFormat = $olFormatPlain^ ERROR

I have office 2000.

Edited by bartekd
Posted

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?

Posted

"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?

Posted

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?

  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...