java ncso发送电邮

In Windows there is no way to natively send mail from the Command Prompt, but because PowerShell allows you to use the underlying .Net Framework, you can easily create and send an  e-mail from the command line.

在Windows中,无法从命令提示符本地发送邮件,但是由于PowerShell允许您使用基础的.Net Framework,因此您可以轻松地从命令行创建和发送电子邮件。

Note: I have uploaded a sample over here, due to many requests.

注意:由于许多要求,我已经在此处上传了一个示例。

从PowerShell发送电子邮件 (Sending Email From PowerShell)

Note: We decided to use the GMail SMTP Servers for this article, that means you will need a GMail account to send mail using the provided code. However, you could easily hack my script to work with any SMTP Server should you want to.

注意:本文决定使用GMail SMTP服务器,这意味着您将需要一个GMail帐户才能使用提供的代码发送邮件。 但是,如果需要,您可以轻松地破解我的脚本以与任何SMTP服务器一起使用。

The first thing you need to do is fire up PowerShell.

您需要做的第一件事是启动PowerShell。

It’s pretty easy to send an e-mail from PowerShell, all you need to do is copy the template we provided and change some of the details.

从PowerShell发送电子邮件非常容易,您所需要做的就是复制我们提供的模板并更改一些详细信息。

$EmailFrom = “yourgmailadress@gmail.com”

$ EmailFrom =“ yourgmailadress@gmail.com”

$EmailTo = “destination@somedomain.com”

$ EmailTo =“ destination@somedomain.com”

$Subject = “The subject of your email”

$ Subject =“您的电子邮件主题”

$Body = “What do you want your email to say”

$ Body =“您希望您的电子邮件说什么”

$SMTPServer = “smtp.gmail.com”

$ SMTPServer =“ smtp.gmail.com”

$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)

$ SMTPClient =新对象Net.Mail.SmtpClient($ SmtpServer,587)

$SMTPClient.EnableSsl = $true

$ SMTPClient.EnableSsl = $ true

$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“usr”, “pass”);

$ SMTPClient.Credentials =新对象System.Net.NetworkCredential(“ usr”,“ pass”);

$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

$ SMTPClient.Send($ EmailFrom,$ EmailTo,$ Subject,$ Body)

You will need to change the following:

您将需要更改以下内容:

  • $EmailFrom = Your GMail address.

    $ EmailFrom =您的GMail地址。

  • $EmailTo = The recipient’s email address.

    $ EmailTo =收件人的电子邮件地址。

  • $Subject = What you want the subject of the mail to say.

    $ Subject =您希望邮件主题说什么。

  • $Body = What you want the main part of the mail to say.

    $ Body =您希望邮件的主要部分说什么。

  • usr = You will need to replace this with your GMail username.

    usr =您将需要用您的GMail用户名替换它。

  • pass = You will need to replace this with your GMail password.

    pass =您需要用您的GMail密码替换它。

Below is an example of me sending mail to myself.

以下是我向自己发送邮件的示例。

Note: For obvious reasons, I removed GMail credentials from the screenshot.

注意:出于明显的原因,我从屏幕快照中删除了GMail凭据。

That’s all there is to it.

这里的所有都是它的。

翻译自: https://www.howtogeek.com/120011/stupid-geek-tricks-how-to-send-email-from-the-command-line-in-windows-without-extra-software/

java ncso发送电邮

java ncso发送电邮_如何在Windows中从命令行发送电子邮件(无需额外的软件)相关推荐

  1. python中访问命令行参数_如何在Python中访问命令行参数?

    我强烈建议argparsePython 2.7及更高版本随附. 该argparse模块减少了样板代码,并使您的代码更健壮,因为该模块可以处理所有标准用例(包括子命令),为您生成帮助和用法,检查和清理用 ...

  2. linux 卸载软件命令_如何在Linux中使用命令行卸载软件

    linux 卸载软件命令 Linux provides different methods for installing software. You can install software from ...

  3. linux查找文件夹命令_如何在Linux中使用命令行查找文件和文件夹

    linux查找文件夹命令 Most people use a graphical file manager to find files in Linux, such as Nautilus in Gn ...

  4. 卸载 linux 命令行,如何在 Ubuntu 中使用命令行卸载 CrossOver

    在 Ubuntu 中如果我们想要使用 Windows 应用程序,那么可以安装一个 CrossOver,在此已经为大家介绍过了这款系统兼容软件的各种优势,在此便不一一阐述了. 在此之前为大家介绍过在 U ...

  5. .net 发送电邮_关于如何使用.NET发送电子邮件的快速参考

    .net 发送电邮 介绍 许多.NET应用程序出于各种原因都需要发送电子邮件. 本文将提供有关如何使用VB.NET发送电子邮件的快速示例. 给出的示例可以轻松转换为C#.NET. 存储电子邮件凭证 如 ...

  6. 禁用键盘快捷键_如何在Windows中使用键盘快捷键临时禁用键盘

    禁用键盘快捷键 If you've got a pet or small child, you know that an unguarded keyboard can spell disaster-o ...

  7. mac命令行将输出写入文件_如何在Linux中使用命令行将PDF文件转换为可编辑文本...

    mac命令行将输出写入文件 There are various reasons why you might want to convert a PDF file to editable text. M ...

  8. eclipse中自定义视图_如何在Windows中自定义文件夹视图设置

    eclipse中自定义视图 While the Windows File Explorer seems somewhat simplified compared to older versions, ...

  9. node.js mysql防注入_避免Node.js中的命令行注入安全漏洞

    在这篇文章中,我们将学习正确使用Node.js调用系统命令的方法,以避免常见的命令行注入漏洞. 我们经常使用的调用命令的方法是最简单的child_process.exec.它有很一个简单的使用模式;通 ...

最新文章

  1. conflicts with existing, non-compatible bean definition of same name and class
  2. /boor删除恢复,
  3. python【数据结构与算法】二分模板
  4. yii 2.0 代码阅读 小记
  5. css改变指针形状,css 指针样式
  6. Apache Mesos + Marathon和Java EE
  7. java web容器原理_javaWeb工作原理
  8. LeetCode 1552. 两球之间的磁力(极小极大化 二分查找)
  9. python 渐变色柱形图_Python利用imshow制作自定义渐变填充柱状图(colorbar)
  10. 字符编码过滤器中对特殊的路径进行特殊处理
  11. 破解 Ashley Madison 1100万个口令
  12. 190524每日一句
  13. 思科、华为、华三交换机的线缆检测功能
  14. Android端测试工具有哪些,android移动app测试几款移动端测试工具分享
  15. 智能陈桥五笔输入法 for linux,在Linux下安装陈桥五笔输入法
  16. vmware安装dsm7.0
  17. JS中的List转Map
  18. 实时音频编解码之十一Opus编码
  19. 熊出没机器人光头强_熊出没中光头强太迂腐,这4种物品都能让他身价过亿,却弃而不用...
  20. pyhton 将ASCII码转换为字符char(),将字符转换为ASCII码ord()

热门文章

  1. python(28): 连接oracle环境离线安装及报错解决87,193
  2. 一个女孩的就业之路 ------来自猫扑(mop.com)
  3. JVM内存与垃圾回收篇——JVM与Java体系结构
  4. ica人脸识别 matlab,ICA算法和人脸识别程序
  5. 一个五年程序员的学习状态
  6. Silverlight5_Tools安装出错解决办法
  7. k8s删除node节点
  8. Mars的自语重出江湖,祝大家端午节安康
  9. 苹果系列手机清除的文件如何恢复的呢
  10. 通过wlanapi连接无线网络