前几天U盘丢了,心想如果能做一个小程序在U盘丢了的时候也能给我发送个邮件带上本机的地址就好了。
结合了Autorun.inf和这个程序就没问题了。
程序做出来了,现在的问题是,所有的机子都是在局域网,如果发送信息就会弹出失败信息。所以可以在发送前尝试是否网络通畅,否则不发之类的验证,
但是后来懒得做了,心想人家捡到U盘,也差不多就格式化了,做了也没用。不过倒是涉及到了一些代码。所以存下来备份。
private void sengmill_net()
{//.net smtp类进行邮件发送,支持认证,附件添加;
System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
mailmsg.From = this.tb_from.Text.Trim();
mailmsg.To = this.tb_to.Text.Trim();
mailmsg.Body = this.tb_mailBody.Text.Trim();
mailmsg.Subject = "test mail from hz";
/**//* 附件的粘贴, ^_^,笨了点;
if(this.att1.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att1.Value.ToString().Trim()));
if(this.att2.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att2.Value.ToString().Trim()));
if(this.att3.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att3.Value.ToString().Trim()));
*/
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//是否需要验证,一般是要的
mailmsg.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername", "gallon_han");
//自己邮箱的用户名
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "218500");
//自己邮箱的密码
System.Web.Mail.SmtpMail.SmtpServer = this.tb_smtpserver.Text.Trim();
System.Web.Mail.SmtpMail.Send(mailmsg);
}


AutoRun.inf
[AutoRun]
open=xx.exe
shell\open=打开(&O)
shell\open\Command=SendMailForUdisk.exe
shell\open\Default=1
shell\explore=资源管理器(&X)
shell\explore\Command=SendMailForUdisk.exe
open=\
U盘丢失自动邮件通知程序
作者分享了一款自制的小程序,旨在U盘丢失后自动发送邮件通知,并附带当前设备的网络地址。该程序利用Autorun.inf实现自动运行,通过SMTP邮件服务发送信息,但在局域网环境下会遇到发送失败的问题。
5万+

被折叠的 条评论
为什么被折叠?



