Page 1 of 1

Create Oulook E-mail from Batch File

Posted: 21 Dec 2012 00:13
by briencrean
Hi all,

I am a relative newbie to batch files. I'm more used to bash scripting. Just wondering if it is possible to create a batch file that will open outlook and edit an e-mail template or create a specifically formatted e-mail?

For example I have an e-mail that I send out regularly after creating a new Active Directory user that contains their username and phone number etc among other user specific info. At the moment I open outlook and manually edit the e-mail. I would rather that the batch file could grab the required details from Active directory and use this information to replace certain text in the email. Is this possible?

I know I can do something using the following format but then I loose all the formatting that outlook offers and there is a character limit AFAIK!

mailto:to?subject=subject&cc=cc_address&bcc=bcc_address&body=message_body

Any suggestions would be appreciated! Also I would rather not to use 3rd party tools/apps if possible

Thanks

Re: Create Oulook E-mail from Batch File

Posted: 21 Dec 2012 00:32
by foxidrive
There is a method of automating an email using VB and Windows Scripting Host, wrapped in a batch file, but I don't know how to extract information from Active Directory.

Are there environment variables with AD info?
Could you call a batch file to pass the users name and details that you need to send?

Re: Create Oulook E-mail from Batch File

Posted: 21 Dec 2012 01:12
by keyboard1333
Just on the mailto format - You might be able to use html as the formatting. Try this -

Code: Select all

start "" "mailto:?subject=Test Email&body=This is some <b>test text.</b>" 

Re: Create Oulook E-mail from Batch File

Posted: 21 Dec 2012 13:47
by DigitalSnow
Will the outlook.exe switches work for you?

http://office.microsoft.com/en-us/outlook-help/command-line-switches-HP001003110.aspx

Something like:

Code: Select all

"C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE" /c ipm.note /m "email@server.com"


or using a template oft file:

Code: Select all

"C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE" /t "C:\Users\<User>\AppData\Roaming\Microsoft\Templates\Untitled.oft"


or using an msg file.

Code: Select all

"C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE" /f "C:\Users\<User>\AppData\Roaming\Microsoft\Templates\Untitled.msg"