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

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

问题描述

在Stack Overflow的另一篇文章中,名为James L.的用户提供了一个有用的脚本,用于将7-Zip添加到Windows中的发送到选项。我想知道通过将结果发送给附在电子邮件上,再一步采取相同的原则是多么困难?
我创建的大部分Zip都是为了发送电子邮件而完成的,这样可以减少一次点击。唯一的障碍是它无法创建一个自解压缩的.exe文件来附加。

解决方案

这里有三个脚本可以一起使用。



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

 设置Ag = Wscript .Arguments 
设置fso = CreateObject(Scripting.FileSystemObject)
设置ts = fso.OpenTextFile(Ag(0),8,vbtrue)
BlankZip =PK& Chr(5)& Chr(6)
对于x = 0到17
BlankZip = BlankZip& Chr(0)
下一个
ts.Write BlankZip

将文件夹添加到zip 。 DestinationZip SourceFolder

 设置objShell = CreateObject(Shell.Application)
设置Ag = Wscript.Arguments
set WshShell = WScript.CreateObject(WScript.Shell)

Set SrcFldr = objShell.NameSpace(Ag(1))
设置DestFldr = objShell。 NameSpace(Ag(0))
设置FldrItems = SrcFldr.Items
DestFldr.CopyHere FldrItems& H214
Msgbox已完成
pre>

发送邮件和附件文件。

 设置emailObj = CreateObject (CDO.Message)
emailObj.From =dc@gmail.com

emailObj.To =dc@gmail.com

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

emailObj.AddAttachmentc:\windows\win.ini

设置emailConfig = emailObj.Configuration

emailConfig.Fields(http://schemas.microsoft.com/cdo/configuration/smtpserver)=smtp.gmail.com
emailConfig。字段(http://schemas.microsoft.com/cdo/configuration/smtpser verport)= 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

如果err.number = 0,那么MsgboxDone
/ pre>

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 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

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"

Send mail and attach file.

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"

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

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