【问题标题】:using Windows send-to for creating a one step send to>zip>to email使用 Windows 发送至创建一步发送至>zip>至电子邮件
【发布时间】:2016-05-08 14:54:38
【问题描述】:

在 Stack Overflow 上的另一篇文章中,一位名叫 James L. 的用户展示了一个有用的脚本,用于将 7-Zip 添加到 Windows 中的“发送到选项”中。我想知道通过将结果发送到电子邮件中来进一步采取同样的原则有多难? 我创建的大多数拉链都是为了通过电子邮件发送给他们的,这将减少到一键。唯一的障碍是它无法创建要附加的自解压“.exe”文件。

【问题讨论】:

  • 链接到其他帖子?我不知道你在说什么,但听起来很有趣。
  • 在 Powershell 中压缩文件并将其作为电子邮件发送非常容易。有很多可用的示例。
  • 链接到 James L.stackoverflow.com/questions/16795607/…987654321@发布的脚本

标签: email batch-file 7zip


【解决方案1】:

您可以将以下三个脚本拼接在一起。

CreateBlankZip.vbs Zipname 作为参数传递,如果名称中有空格,请使用引号。

Set Ag=Wscript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Ag(0), 8, vbtrue)
BlankZip = "PK" & Chr(5) & Chr(6)
For x = 0 to 17
    BlankZip = BlankZip & Chr(0)
Next
ts.Write BlankZip

将文件夹添加到 zip。 DestinationZip 源文件夹

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")

Set SrcFldr=objShell.NameSpace(Ag(1))
Set DestFldr=objShell.NameSpace(Ag(0))
Set FldrItems=SrcFldr.Items
DestFldr.CopyHere FldrItems, &H214
Msgbox "Finished"

发送邮件并附加文件。

Set emailObj      = CreateObject("CDO.Message")
emailObj.From     = "dc@gmail.com"

emailObj.To       = "dc@gmail.com"

emailObj.Subject  = "Test CDO"
emailObj.TextBody = "Test CDO"

emailObj.AddAttachment "c:\windows\win.ini"

Set emailConfig = emailObj.Configuration

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")    = 2  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = true 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "MyName"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "Ppassword1"
emailConfig.Fields.Update

emailObj.Send

If err.number = 0 then Msgbox "Done"

【讨论】:

  • 我更喜欢类似于使用 SendTo 中已有的选项的东西。如 Sendto 压缩 Zip + SendTo 电子邮件收件人。如果我可以在创建 zip 后将它们串在一起,它将附加到 Outlook 中的电子邮件中,以便处理和发送。操作系统是 Win10-X64 + Outlook 2016。我还不能让你的脚本工作,但仍在尝试。
猜你喜欢
  • 1970-01-01
  • 2019-02-24
  • 1970-01-01
  • 2011-03-25
  • 2012-07-30
  • 2014-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多