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

邮件发送 _mail_04   mailmsg.Fields.Add(
"[url]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate[/url]""1");
邮件发送 _mail_04   
//是否需要验证,一般是要的    
邮件发送 _mail_04
   mailmsg.Fields.Add 
邮件发送 _mail_04    (
"[url]http://schemas.microsoft.com/cdo/configuration/sendusername[/url]""gallon_han"); 
邮件发送 _mail_04   
//自己邮箱的用户名    
邮件发送 _mail_04
   mailmsg.Fields.Add("[url]http://schemas.microsoft.com/cdo/configuration/sendpassword[/url]""218500");
邮件发送 _mail_04   
//自己邮箱的密码 
邮件发送 _mail_04
   System.Web.Mail.SmtpMail.SmtpServer = this.tb_smtpserver.Text.Trim();
邮件发送 _mail_04   System.Web.Mail.SmtpMail.Send(mailmsg);
邮件发送 _邮件_27  }

邮件发送 _C#_28
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=\