Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Option 1</strong><br> You didn't say much about your environment, but assuming you have it available you could use a PowerShell script; one example is <a href="http://exchangeserverpro.com/powershell-how-to-send-email" rel="noreferrer">here</a>. The essence of this is:</p> <pre><code>$smtp = New-Object Net.Mail.SmtpClient("ho-ex2010-caht1.exchangeserverpro.net") $smtp.Send("reports@exchangeserverpro.net","administrator@exchangeserverpro.net","Test Email","This is a test") </code></pre> <p>You could then launch the script from the command line as per <a href="http://technet.microsoft.com/en-us/library/ee176949.aspx#EBAA" rel="noreferrer">this example</a>:</p> <pre><code>powershell.exe -noexit c:\scripts\test.ps1 </code></pre> <p>Note that PowerShell 2.0, which is installed by default on Windows 7 and Windows Server 2008R2, includes a simpler <a href="http://technet.microsoft.com/en-us/library/dd347693.aspx" rel="noreferrer"><code>Send-MailMessage</code></a> command, making things easier.</p> <p><strong>Option 2</strong><br> If you're prepared to use third-party software, is something line <a href="http://caspian.dotconf.net/menu/Software/SendEmail/" rel="noreferrer">this SendEmail command-line tool</a>. It depends on your target environment, though; if you're deploying your batch file to multiple machines, that will obviously require inclusion (but not formal installation) each time.</p> <p><strong>Option 3</strong><br> You could drive Outlook directly from a VBA script, which in turn you would trigger from a batch file; this would let you send an email using Outlook itself, which looks to be closest to what you're wanting. There are two parts to this; first, figure out the VBA scripting required to send an email. There are lots of examples for this online, including from Microsoft <a href="http://support.microsoft.com/kb/161088?wa=wsignin1.0" rel="noreferrer">here</a>. Essence of this is:</p> <pre><code>Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath) Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment Set objOutlook = CreateObject("Outlook.Application") Set objOutlookMsg = objOutlook.CreateItem(olMailItem) With objOutlookMsg Set objOutlookRecip = .Recipients.Add("Nancy Davolio") objOutlookRecip.Type = olTo ' Set the Subject, Body, and Importance of the message. .Subject = "This is an Automation test with Microsoft Outlook" .Body = "This is the body of the message." &amp;vbCrLf &amp; vbCrLf .Importance = olImportanceHigh 'High importance If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(AttachmentPath) End If For Each ObjOutlookRecip In .Recipients objOutlookRecip.Resolve Next .Save .Send End With Set objOutlook = Nothing End Sub </code></pre> <p>Then, launch Outlook from the command line with the <code>/autorun</code> parameter, as per <a href="https://stackoverflow.com/a/9261561/55487">this answer</a> (alter path/macroname as necessary):</p> <pre><code>C:\Program Files\Microsoft Office\Office11\Outlook.exe" /autorun macroname </code></pre> <p><strong>Option 4</strong><br> You could use the same approach as option 3, but move the Outlook VBA into a PowerShell script (which you would run from a command line). Example <a href="http://blogs.msdn.com/b/jmanning/archive/2007/01/25/using-powershell-for-outlook-automation.aspx" rel="noreferrer">here</a>. This is probably the tidiest solution, IMO.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload