Create Oulook E-mail from Batch File

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
briencrean
Posts: 1
Joined: 20 Dec 2012 23:55

Create Oulook E-mail from Batch File

#1 Post by briencrean » 21 Dec 2012 00:13

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Create Oulook E-mail from Batch File

#2 Post by foxidrive » 21 Dec 2012 00:32

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?

keyboard1333
Posts: 21
Joined: 23 Aug 2012 00:07

Re: Create Oulook E-mail from Batch File

#3 Post by keyboard1333 » 21 Dec 2012 01:12

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

DigitalSnow
Posts: 20
Joined: 21 Dec 2012 13:36
Location: United States

Re: Create Oulook E-mail from Batch File

#4 Post by DigitalSnow » 21 Dec 2012 13:47

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"

Post Reply