rosaz Posted September 23, 2009 Posted September 23, 2009 Hello, I'm trying to automate an Outlook email that will have spaces between the lines, like this: "Hello, Your request has been received. Thank you!" Only I'm not sure how to add the spaces in. I've tried using Chr(10) and so far, no luck. Here's my code: objOutlook = ObjCreate ("Outlook.Application") $objOutlook.Session.Logon $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem($olMailItem) With $oOMail .To = $to .Subject = $subject .Body = Chr(10) & "Hello," & Chr(10)& Chr(10) & "Your request has been received." & Chr(10) & Chr(10) & "Thank you!" EndWith Thank you for any suggestions!
jvanegmond Posted September 23, 2009 Posted September 23, 2009 You're looking for the @CRLF macro. Instead of Chr(10) use @CRLF. github.com/jvanegmond
JDouglas60 Posted October 21, 2009 Posted October 21, 2009 You're looking for the @CRLF macro. Instead of Chr(10) use @CRLF.I'd like to take this "Body" question a little further. Using @CRLF works, but in our case, we need to automate it more. We have an external program that is actually building all the components (addresses, subject, attachments, body) of the email. We then use this type of email script to present the user with Outlook and all the components are populated for them. Currently our external program is populating an ini file with the all the email components and then the autoit script does IniReadSection to assign varibles that are used in the email script.This all works great but I am resticted to just a single line of text for the body (no line breaks) because of the variable.Any thoughts on how I can use a varible (.Body = $bodytext) and have it include line breaks?Or perhaps is there a way I can use a variable to use a pre-formatted html file to create the body text?Thanks
Juvigy Posted October 22, 2009 Posted October 22, 2009 Use this: .HTMLBody = "your text <BR><BR>yor second line<BR><BR>more text" You can use other formatting html tags too.
JDouglas60 Posted October 22, 2009 Posted October 22, 2009 Use this: .HTMLBody = "your text <BR><BR>yor second line<BR><BR>more text" You can use other formatting html tags too. Thanks... the HTMLBody fits the bill perfectly. From crusing these forums I've figured out alot of the syntax in this type of email script but I'd like to know more. Is this syntax and all the various options listed somewhere? Is it a microsoft spec? Thanks again for the quick response!
Juvigy Posted October 22, 2009 Posted October 22, 2009 Yes , try the msdn . Most of it is there: http://msdn.microsoft.com/en-us/library/aa210946%28office.11%29.aspx
jvanegmond Posted October 22, 2009 Posted October 22, 2009 Thanks... the HTMLBody fits the bill perfectly.From crusing these forums I've figured out alot of the syntax in this type of email script but I'd like to know more. Is this syntax and all the various options listed somewhere? Is it a microsoft spec?Thanks again for the quick response!Of course this is documented. Googling for "Outlook.Application HTMLBody" the documentation was result #1.And from there you should find this pretty quickly:http://msdn.microsoft.com/en-us/library/aa210946(office.11).aspx github.com/jvanegmond
JDouglas60 Posted October 22, 2009 Posted October 22, 2009 Of course this is documented. Googling for "Outlook.Application HTMLBody" the documentation was result #1.And from there you should find this pretty quickly:http://msdn.microsoft.com/en-us/library/aa210946(office.11).aspxOk.. well thats kinda obvious. Sorry that I had had "forum tunnel focus".I started digging into this MS documentation and unfortunately they fail to include in this site what the numeric values are for the differant MailItem object properties. http://msdn.microsoft.com/en-us/library/bb207134.aspx is a good example where some user posted the numeric information for them at the bottom of the page.None the less, this is good resource & I'll just have keep digging to uncover it all. Thanks!
jvanegmond Posted October 22, 2009 Posted October 22, 2009 Ok.. well thats kinda obvious. Sorry that I had had "forum tunnel focus".I started digging into this MS documentation and unfortunately they fail to include in this site what the numeric values are for the differant MailItem object properties. http://msdn.microsoft.com/en-us/library/bb207134.aspx is a good example where some user posted the numeric information for them at the bottom of the page.None the less, this is good resource & I'll just have keep digging to uncover it all. Thanks!Look at the description:Returns or sets an OlBodyFormat constant indicating the format of the body text. Read/write.Click the link: http://msdn.microsoft.com/en-us/library/bb208058.aspxSpecifies the format of the body text of an item.Name Value DescriptionolFormatHTML 2 HTML formatolFormatPlain 1 Plain formatolFormatRichText 3 Rich text formatolFormatUnspecified 0 Unspecified format github.com/jvanegmond
JDouglas60 Posted October 22, 2009 Posted October 22, 2009 Look at the description:Returns or sets an OlBodyFormat constant indicating the format of the body text. Read/write.Click the link: http://msdn.microsoft.com/en-us/library/bb208058.aspxSpecifies the format of the body text of an item.Name Value DescriptionolFormatHTML 2 HTML formatolFormatPlain 1 Plain formatolFormatRichText 3 Rich text formatolFormatUnspecified 0 Unspecified formatThanks again for pointing me in the right direction. I think I would have gotten here eventually, but you have made the discovery process much faster.
jvanegmond Posted October 22, 2009 Posted October 22, 2009 No problem, it took me a while too to get familiar with MSDN. : ) github.com/jvanegmond
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