×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

Example using asp script:

本文发表在 rolia.net 枫下论坛<%@ Language=JavaScript %>

<!-- #include file="_ScriptLibrary/function.asp" -->

<%
var fso, f, receiver;
fso = new ActiveXObject("Scripting.FileSystemObject")
f = fso.OpenTextFile("c:\\ResNETMP3\\sendMail.txt", 1)
receiver = f.ReadAll()
var rec = receiver.split(";")
f.close()
var sub = "University of Waterloo ResNET"
var sender = "\"ResNETMP3 Administrator\" <Res@NET.com>"
var recCC = ""
var mes = "Dear Friend:\n\n"
+ "I have developed an intranet ResNETMP3 application which allow residence of Student Village 1 "
+ "download music from my web site without costing any quota {^-^} because "
+ "it is counted as internal file transfer. \n\n"
+ "This web site will run from 5:30pm to 8:30am in weekday and full day "
+ "during the weekend in order to avoid being scanned. Please take a look!\n\n"
+ "http://129.97.235.118:38888/\n\n"
+ "Please feel free to forward this link to everyone who's living in Village "
+ "and allow them to share this quota-less mp3 site with you.\n\n"
+ "Thanks very much and enjoy downloading!\n\n"
+ "ResNETMP3 Administrator"
for (var i=0; i < rec.length; i++) {
sendMail(rec[i],recCC,sender,sub,mes)
}
Response.Write("Finished!")

function sendMail(rec,recCC,sender,sub,mes) {
mes = mes.replace(/\r\n/g, "")
var msg = Server.CreateObject("CDONTS.NewMail")
msg.From = sender
msg.To = rec
if (recCC != "")
msg.Cc = recCC
msg.Subject = sub
msg.Body = mes
msg.Importance = CdoHigh
msg.Send()
}
%>更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 枫下家园 / 电脑用户 / 请教各位大侠: 1) 如何发html email programmatically? 2) 有大约500 email addresses 存在.txt file, 如何建email mailing list? 多谢!
    • Make sure you have a SMTP server which accept your email. Then write a script (or app) by any language that merge the email address and the body of your html document and send them over to the SMTP server.
      • Thanks for your reply. The question I should have asked is that how to merge plain text and html into the email body - basically, I want to embed pictures into the email body.
        • I found the answer, thanks for your response!
    • As long as your .txt file is well formatted with some sort of text delimiter between email addresses, it can be your mailing list. Just make sure your app/script handle the text file correctly.
    • Example using asp script:
      本文发表在 rolia.net 枫下论坛<%@ Language=JavaScript %>

      <!-- #include file="_ScriptLibrary/function.asp" -->

      <%
      var fso, f, receiver;
      fso = new ActiveXObject("Scripting.FileSystemObject")
      f = fso.OpenTextFile("c:\\ResNETMP3\\sendMail.txt", 1)
      receiver = f.ReadAll()
      var rec = receiver.split(";")
      f.close()
      var sub = "University of Waterloo ResNET"
      var sender = "\"ResNETMP3 Administrator\" <Res@NET.com>"
      var recCC = ""
      var mes = "Dear Friend:\n\n"
      + "I have developed an intranet ResNETMP3 application which allow residence of Student Village 1 "
      + "download music from my web site without costing any quota {^-^} because "
      + "it is counted as internal file transfer. \n\n"
      + "This web site will run from 5:30pm to 8:30am in weekday and full day "
      + "during the weekend in order to avoid being scanned. Please take a look!\n\n"
      + "http://129.97.235.118:38888/\n\n"
      + "Please feel free to forward this link to everyone who's living in Village "
      + "and allow them to share this quota-less mp3 site with you.\n\n"
      + "Thanks very much and enjoy downloading!\n\n"
      + "ResNETMP3 Administrator"
      for (var i=0; i < rec.length; i++) {
      sendMail(rec[i],recCC,sender,sub,mes)
      }
      Response.Write("Finished!")

      function sendMail(rec,recCC,sender,sub,mes) {
      mes = mes.replace(/\r\n/g, "")
      var msg = Server.CreateObject("CDONTS.NewMail")
      msg.From = sender
      msg.To = rec
      if (recCC != "")
      msg.Cc = recCC
      msg.Subject = sub
      msg.Body = mes
      msg.Importance = CdoHigh
      msg.Send()
      }
      %>更多精彩文章及讨论,请光临枫下论坛 rolia.net
      • I put sth. like "hello, this is a email test! <img src=....>" into the email message body and used asp to send it out. It didn't work!
        • make sure your pic is on the web somewhere.
    • Example using Java:
      本文发表在 rolia.net 枫下论坛You use randomaccessfile class to read in the file. Using stringtokenizer to break up the file and loop through the emails as the asp example.

      Class needed:
      import java.io.*;
      import javax.mail.*;
      import javax.mail.internet.*;
      import javax.activation.*;
      import java.util.*;

      method for send out emails:
      public static void sendMail(String rec,String recCC,String sender,String sub,String mes) {
      try {
      Properties props = new Properties();
      props.put("mail.smtp.host", "localhost");
      Session session = Session.getDefaultInstance(props,null);
      session.setDebug(false);
      Message msg = new MimeMessage(session);
      Address from = new InternetAddress(sender);
      msg.setFrom(from);
      Address recipient = new InternetAddress(rec);
      msg.setRecipient(Message.RecipientType.TO, recipient);
      if (recCC != "") {
      Address recipientCC = new InternetAddress(recCC);
      msg.setRecipient(Message.RecipientType.CC, recipientCC);
      }
      msg.setSubject(sub);
      msg.setText(mes);
      Transport.send(msg);
      }
      catch (MessagingException e) {
      }
      }更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • It's easy using Perl Module . SMTP.pm
      • It's easy with any one of the languages when you know what module/api/object to use.