【问题标题】:Make Powershell V2 open a new mail message from mailto link使 Powershell V2 从 mailto 链接打开一个新的邮件消息
【发布时间】:2017-11-08 21:09:55
【问题描述】:

我正在尝试让 Powershell V2 脚本在默认邮件应用程序中打开一个新的邮件消息窗口,其中预先填写了收件人、抄送、主题和正文字段。在批处理脚本中,我只需使用 mailto 函数,效果很好。但是,我无法在 Powershell 中进行这项工作,并且 Send-MailMessage cmdlet 正在询问用户可能没有的信息。

脚本将被多个用户使用,所以我无法将发送者/服务器信息硬编码到脚本中;用户还需要能够在发送电子邮件之前对其进行更改。

是否有一个 cmdlet 允许我只填写我之前提到的四个字段,在默认邮件应用程序中打开(但它是在系统中设置的),并允许用户在发送前对邮件进行更改?

我已经为此寻找了一个月的答案,但目前还没有成功。任何帮助将不胜感激。

【问题讨论】:

    标签: email powershell mailto


    【解决方案1】:

    如果您向Start-Process 提供带有mailto: 方案的URI,Windows 将自动找出与之关联的应用程序(无论是Outlook、Thunderbird、Windows Mail 还是您喜欢的任何应用程序)并启动它:

    例如:

    PS C:\> Start-Process "mailto:dhub01@domain.tld"
    # Start-Process immediately returns but a new mail message is launched
    

    就像任何其他 URI 一样,mailto: URI 可以附加查询:

    PS C:\> Start-Process "mailto:dhub01@domain.tld?Subject=This is a Subject&Cc=dhub02@domain.tld&Body=This is the contents of the message"
    # The message is created with the above values in place (at least in Outlook)
    

    【讨论】:

      【解决方案2】:

      我可以确认,Mathias 的语法:

      PS C:\> Start-Process "mailto:dhub01@domain.tld?Subject=This is a Subject&Cc=dhub02@domain.tld&Body=This is the contents of the message"
      # Start-Process immediately returns but a new mail message is launched
      

      也适用于 Thunderbird。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-03-28
        • 2019-12-03
        • 1970-01-01
        • 2015-03-22
        • 2011-07-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多