Is it possible to send an email using a batch file?
I know how to do it using Excel/VBA: CDO code. I have a number of batch files that I would like an email sent to me once they complete. The batch files reside on a server.
Thanks,
John
Send eMail Using Batch File
-
- GoldLounger
- Posts: 2601
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Send eMail Using Batch File
Regards,
John
John
-
- Administrator
- Posts: 12438
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
-
- Administrator
- Posts: 77302
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Send eMail Using Batch File
Perhaps you can use Send mail from a batch file. This uses " IIS's SMTP service running on the local machine".
Or try Blat - A Win32 Command Line SMTP Mailer.
(If you have Exchange Server, you can use the mapisend command-line utility from the Exchange Resource Kit)
Or try Blat - A Win32 Command Line SMTP Mailer.
(If you have Exchange Server, you can use the mapisend command-line utility from the Exchange Resource Kit)
Regards,
Hans
Hans
-
- GoldLounger
- Posts: 2601
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Re: Send eMail Using Batch File
Hans,
I used you first link; using "IIS's SMTP service running on the local machine". It worked perfectly as long as the same email address is part of the same domain.
I'm not sure why it is restricted to the same domain but I would like to send an email to my gmail account as well.
Regards,
John
I used you first link; using "IIS's SMTP service running on the local machine". It worked perfectly as long as the same email address is part of the same domain.
I'm not sure why it is restricted to the same domain but I would like to send an email to my gmail account as well.
Regards,
John
Regards,
John
John
-
- Administrator
- Posts: 77302
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Send eMail Using Batch File
I hope that someone else can help you with this; I don't have any experience with this kind of thing. Sorry...
Regards,
Hans
Hans
-
- StarLounger
- Posts: 80
- Joined: 24 Jan 2010, 13:09
- Location: Brantford, Ontario, Canada
Re: Send eMail Using Batch File
I've usedSendeMail previously. Very simple command line interface.
-
- GoldLounger
- Posts: 2601
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Re: Send eMail Using Batch File
Hans,
How would one incorporate more then one email address in the following code? I have tested it but cannot get it to send to more then one email address.
Regards,
John
How would one incorporate more then one email address in the following code? I have tested it but cannot get it to send to more then one email address.
Code: Select all
@echo off & setlocal
:: set the temp file location
set tempmail=%temp%\tempmail.%random%.txt
:: echo the basic headers to the temp file
echo To: "Scripting Test" ^<test@paulsadowski.com^> > %tempmail%
echo From: "Me" ^<me@my.com^> >> %tempmail%
echo Subject: Test2 >> %tempmail%
:: echo the blank line that separates the header from the body text
echo.>>%tempmail%
:: echo the body text to the temp file
echo First line of body text.>> %tempmail%
echo Second line of body text.>> %tempmail%
:: move the temp file to the mail pickup directory
:: adjust this location for your system
move %tempmail% c:\inetpub\mailroot\pickup
set tempmail=
endlocal
John
Regards,
John
John
-
- Administrator
- Posts: 77302
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Send eMail Using Batch File
Have you tried something like
echo To: "John Doe" ^<john.doe@company.com^>, "Mary Lamb" ^<m.lamb@other.com^> > %tempmail%
i.e. separate the recipients with a comma?
BTW, if you don't want to use display names, the e-mail addresses are sufficient:
echo To: john.doe@company.com, m.lamb@other.com > %tempmail%
echo To: "John Doe" ^<john.doe@company.com^>, "Mary Lamb" ^<m.lamb@other.com^> > %tempmail%
i.e. separate the recipients with a comma?
BTW, if you don't want to use display names, the e-mail addresses are sufficient:
echo To: john.doe@company.com, m.lamb@other.com > %tempmail%
Regards,
Hans
Hans
-
- GoldLounger
- Posts: 2601
- Joined: 26 Jan 2010, 16:31
- Location: Southern California