使用 Windows 发送到创建一步发送到>zip>到电子邮件 [英] using Windows send-to for creating a one step send to>zip>to email

查看:22
本文介绍了使用 Windows 发送到创建一步发送到>zip>到电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Stack Overflow 上的另一篇文章中,名为 James L. 的用户展示了一个有用的脚本,用于将 7-Zip 添加到 Windows 的发送到选项"中.我想知道通过将结果附加到电子邮件中,再采取相同的原则有多难?我创建的大部分 zip 都是为了通过电子邮件发送给他们的,这会将其减少到一次点击.唯一的障碍是它无法创建要附加的自解压.exe"文件.

In another post on Stack Overflow a user named James L. presented a useful script for adding 7-Zip to the Send to Options in Windows. I was wondering how hard it would be to take that same principle one more step by sending the results on to be attached to an email? Most of the zips I create are done in order to email them and this would cut that down to one click. The only obstacle being that it could not create a self-extracting ".exe" file to be attached.

推荐答案

您可以将以下三个脚本组合在一起.

Here are three scripts you can stich together.

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

CreateBlankZip.vbs Zipname passed as a parameter, use quotes if spaces in name.

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 源文件夹

Add folder to zip. DestinationZip SourceFolder

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:windowswin.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"

这篇关于使用 Windows 发送到创建一步发送到>zip>到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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