使用bat文件使用Outlook 2013以编程方式发送电子邮件 [英] programmatically sending email using outlook 2013 using bat file

查看:76
本文介绍了使用bat文件使用Outlook 2013以编程方式发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用bat文件通过Outlook 2013发送电子邮件,但是运行后,它只是打开了一个电子邮件窗口,并填写了收件人等.它停止不发送(附有图像).问题是由于脚本或Outlook版本引起的吗?可以在Outlook 2010中使用吗?

Im trying to use a bat file to send an email using Outlook 2013, however after running it simply opens an email window and after filling in recipient etc. it stops without sending (image attached). Is the problem due to the script or outlook version? Would it work in outlook 2010?

这是我的蝙蝠文件:

"C:\Program Files\Microsoft Office\Office15\OUTLOOK.EXE" /c ipm.note /m "mailto:xxxxxx5@hotmail.com?subject=subject&cc=cc_address&bcc=bcc_address&body=message_body"

推荐答案

您使用的方法无法按预期工作,您需要对其进行脚本编写或使用 VBA 或喜欢.

The method you are using will not work as expected, you need to script it or create some sort of macro using VBA or the likes.

但是,您可以通过在批处理文件中运行Powershell的 Send-MailMessage (在Windows系统上是标准配置)来实现:

However, You could just use your powershell's Send-MailMessage which comes standard on a windows system by running it in a batchfile:

注意!必须是Powershell 2.0或更高版本.

NOTE!! Must be powershell 2.0 or later.

powershell Send-MailMessage 
           -From "someone@someserver.net"
           -To "whoever@gmail.com"
           -Subject "Test email"
           -Body "This is a test"
           -SmtpServer Some_exhange_server_name\

出于可读性考虑,我使用换行符对文本进行了细分,但应该只使用一行.

I broke down the text using newlines for readability, but it should be a single line.

powershell Send-MailMessage -From "someone@someserver.net" -To "whoever@gmail.com" -Subject "Test email" -Body "This is a test" -SmtpServer some_exhange_server_name

或者,您可以跳过所有批处理,而仅创建一个名为 sendmail.ps1 之类的powershell文件,然后输入代码

Alternatively, you could skip batch all together and just create a powershell file called something like sendmail.ps1 and enter the code

Send-MailMessage -From "someone@someserver.net" -To "whoever@gmail.com" -Subject "Test email" -Body "This is a test" -SmtpServer some_exhange_Server_name

这篇关于使用bat文件使用Outlook 2013以编程方式发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆