daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Oct 17th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.  
  4.  
  5. mail_user = ""
  6. mail_pass = ""
  7.  
  8.  
  9. set fso = WScript.CreateObject("Scripting.FileSystemObject")
  10. set file_mailbody = fso.OpenTextFile("お知らせ.txt")
  11. set file_mailaddr = fso.OpenTextFile("mailaddr.txt")
  12. set file_mailresult = fso.OpenTextFile("mail_reslt.txt",8,True)
  13.  
  14.  
  15. set mailbody = file_mailbody.ReadAll();
  16. file_mailbody.close
  17.  
  18. WScript.Echo "送信を開始します。"
  19.  
  20. setMailConfig msg, mail_user, mail_pass
  21.  
  22. Do Until file_mailaddr.AtEndOfStream = true
  23.     set msg = WScript.CreateObject("CDO.Message")
  24.     msg.From = ".jp>";        // 自分のメールアドレス
  25.     msg.Subject = "";// メールの件名
  26.     msg.TextBody = mailbody;
  27.     set line = file_mailaddr.ReadLine
  28.     set spli = line.split("\t")
  29.     var num = spli(0);
  30.     var mailaddr = spli(1);
  31.     WScript.StdOut.Write(spli(0) & ": " & spli(1) & "   ");
  32.     file_mailresult.Write(spli(0) & "   " & spli(1) & " ");
  33.  
  34.     On Error resume next
  35.  
  36.       msg.To   = mailaddr; // 送り先のメールアドレス
  37.       msg.Send();
  38.     if err = 0 then
  39.       WScript.Echo("送信成功");
  40.           file_mailresult.WriteLine("送信成功");
  41.     else
  42.         WScript.Echo("送信失敗");
  43.             var e_description = e.description;
  44.         WScript.Echo("  Error: " + e_description);
  45.             file_mailresult.WriteLine("送信失敗\tError: " + e_description)
  46.     end if
  47.    
  48.  
  49. Loop
  50.  
  51.  
  52. file_mailaddr.Close
  53. file_mailresult.Close
  54.  
  55. WScript.Echo "全件送信完了しました。"
  56.  
  57. sub setMailConfig(msg, user, pass) {
  58.   msg.TextBodyPart.Charset = 'ISO-2022-JP';
  59.   uri = "http://schemas.microsoft.com/cdo/configuration/"
  60.   msg.Configuration.Fields.Item(uri & "sendusing") = 2
  61.   msg.Configuration.Fields.Item(uri & "smtpconnectiontimeout") = 30
  62.   msg.Configuration.Fields.Item(uri & "smtpserver") = "mail.domain.local"
  63.   msg.Configuration.Fields.Item(uri & "smtpserverport") = 25
  64.   msg.Configuration.Fields.Item(uri & "smtpauthenticate") = False
  65.   msg.Configuration.Fields.Item(uri & "smtpusessl") = False
  66.   msg.Configuration.Fields.Item(uri & "sendusername") = user
  67.   msg.Configuration.Fields.Item(uri & "sendpassword") = pass
  68.   msg.Configuration.Fields.Update
  69.  
  70. end sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top