home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 1999 November / PCW9911.BIN / sharewar / prx / wscripts / aspemail.exe / SendMail.asp < prev    next >
Encoding:
Text File  |  1999-01-22  |  4.5 KB  |  159 lines

  1. <OBJECT RUNAT=SERVER PROGID="Persits.MailSender" ID="Mail">
  2. </OBJECT>
  3.  
  4. <%
  5.     Set arrTo        = Session("arrTo")
  6.     Set arrCc        = Session("arrCC")
  7.     Set arrBcc        = Session("arrBcc")
  8.     Set arrFiles    = Session("arrFiles")
  9.  
  10.     ' Handle "Send Message" button
  11.     Mail.Host = "smtp.yourcompany.com"
  12.     If Request("SEND") <> "" Then
  13.         
  14.         ' get addresses from collections
  15.         Items = arrTo.Items
  16.         For i = 0 to arrTo.Count - 1    
  17.             Mail.AddAddress Items(i)
  18.         Next
  19.         Items = arrCc.Items
  20.         For i = 0 to arrCc.Count - 1    
  21.             Mail.AddCc Items(i)
  22.         Next
  23.         Items = arrBcc.Items
  24.         For i = 0 to arrBcc.Count - 1    
  25.             Mail.AddBcc Items(i)
  26.         Next
  27.         Items = arrFiles.Items
  28.         For i = 0 to arrFiles.Count - 1    
  29.             Mail.AddAttachment Items(i)
  30.         Next
  31.  
  32.  
  33.  
  34.         Mail.From = "jsmith@persits.com"
  35.         Mail.FromName = "John Smith"
  36.         Mail.Subject = Request("Subject")
  37.         Mail.Body = Request("Body")
  38.         On Error Resume Next
  39.         if not Mail.Send Then 
  40.             ErrStr = Err.Description
  41.         Else
  42.             arrTo.RemoveAll
  43.             arrCc.RemoveAll
  44.             arrBcc.RemoveAll
  45.             arrFiles.RemoveAll
  46.         End If
  47.         On Error Goto 0
  48.     End If
  49.  
  50.     ' Handle "Add Address" buttons
  51.  
  52.     Session("Count") = Session("Count") + 1
  53.  
  54.     If Request("Address") <> "" Then arrTo.Add Session("Count"), CStr(Request("Address"))
  55.     If Request("CCAddress") <> "" Then arrCc.Add Session("Count"), CStr(Request("CCAddress"))
  56.     If Request("BccAddress") <> "" Then arrBcc.Add Session("Count"), CStr(Request("BccAddress"))
  57.  
  58.     ' Handle Delete command
  59.     If Request("DeleteTo") <> "" Then arrTo.Remove CInt(Request("DeleteTo"))
  60.     If Request("DeleteCc") <> "" Then arrCc.Remove CInt(Request("DeleteCc"))
  61.     If Request("DeleteBcc") <> "" Then arrBcc.Remove CInt(Request("DeleteBcc"))
  62.  
  63. %>
  64.  
  65. <HTML>
  66. <HEAD>
  67. <META NAME="GENERATOR" Content="Microsoft Developer Studio">
  68. <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
  69. <TITLE>Persits Software AspEmail Demo</TITLE>
  70. </HEAD>
  71. <BODY BGCOLOR="#FFFFFF">
  72. <BASEFONT FACE="Arial, Helvetica">
  73.  
  74.  
  75. <TABLE WIDTH="80%" BGCOLOR="#C0C0C0" BORDER=2 CELLPADDING=0 CELLSPACING=3>
  76. <TD>
  77.  
  78. <TABLE WIDTH="100%" BGCOLOR="#C0C0C0" BORDER=0 CELLPADDING=2 CELLSPACING=0>
  79. <TR><TH WxIDTH="10"></TH><TH WxIDTH="85%"></TH><TH WIxDTH="10%"></TH></TR>
  80. <FORM METHOD=GET ACTION="SendMail.asp">
  81.     <TR>
  82.         <TD BGCOLOR="#808080" ALIGN=RIGHT><FONT COLOR="#FFFFFF">To:</FONT></TD>
  83.         <TD BGCOLOR="#E0E0E0">
  84.         <%
  85.             For i = 0 to arrTo.Count - 1
  86.             Keys = arrTo.Keys
  87.             Items = arrTo.Items
  88.                 Response.Write "<A HREF=""SendMail.asp?DeleteTo=" & Keys(i) & """>" & Items(i) & "</A>; "
  89.             Next
  90.         %> 
  91.         </TD>
  92.         <TD BGCOLOR="#E0E0E0"ALIGN=RIGHT><INPUT TYPE=TEXT NAME="Address"><INPUT TYPE=SUBMIT VALUE="Add Address"></TD>
  93.     </TR>
  94.     <TR>
  95.         <TD BGCOLOR="#808080" ALIGN=RIGHT><FONT COLOR="#FFFFFF">Cc:</FONT></TD>
  96.         <TD>
  97.         <%
  98.             For i = 0 to arrCC.Count - 1
  99.             Keys = arrCC.Keys
  100.             Items = arrCC.Items
  101.                 Response.Write "<A HREF=""SendMail.asp?DeleteCc=" & Keys(i) & """>" & Items(i) & "</A>; "
  102.             Next
  103.         %> 
  104.         </TD>
  105.         <TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME="CCAddress"><INPUT TYPE=SUBMIT VALUE="Add Address"></TD>
  106.     </TR>
  107.     <TR>
  108.         <TD BGCOLOR="#808080" ALIGN=RIGHT><FONT COLOR="#FFFFFF">Bcc:</FONT></TD>
  109.         <TD BGCOLOR="#E0E0E0">
  110.         <%
  111.             For i = 0 to arrBcc.Count - 1
  112.             Keys = arrBcc.Keys
  113.             Items = arrBcc.Items
  114.                 Response.Write "<A HREF=""SendMail.asp?DeleteBcc=" & Keys(i) & """>" & Items(i) & "</A>; "
  115.             Next
  116.         %> 
  117.         </TD>
  118.         <TD BGCOLOR="#E0E0E0" ALIGN=RIGHT><INPUT TYPE=TEXT NAME="BCCAddress"><INPUT TYPE=SUBMIT VALUE="Add Address"></TD>
  119.     </TR>
  120. </FORM>
  121.     <TR>
  122.         <TD BGCOLOR="#808080" ALIGN=RIGHT><FONT COLOR="#FFFFFF">Attachments:</FONT></TD>
  123.         <TD>
  124.         <%
  125.             For i = 0 to arrFiles.Count - 1
  126.             Keys = arrFiles.Keys
  127.             Items = arrFiles.Items
  128.                 Response.Write Items(i) & "; "
  129.             Next
  130.         %> 
  131.         </TD>
  132.         <TD ALIGN=RIGHT><A HREF="Attachments.asp">Edit Attachments</A></TD>
  133.     </TR>
  134.  
  135. <FORM METHOD=POST ACTION="SendMail.asp">
  136.     <TR>
  137.         <TD BGCOLOR="#808080" ALIGN=RIGHT><FONT COLOR="#FFFFFF">Subject:</FONT></TD><TD BGCOLOR="#E0E0E0"><INPUT TYPE=TEXT SIZE=40 NAME="Subject"></TD><TD ALIGN=RIGHT BGCOLOR="#E0E0E0"> </TD>
  138.     </TR>
  139.     <TR>
  140.         <TD ALIGN=LEFT BGCOLOR="#C0C0C0" COLSPAN=3><TEXTAREA NAME="Body" COLS=90 ROWS=20></TEXTAREA></TD>
  141.     </TR>
  142.     <TR>
  143.         <TD BGCOLOR="#C0C0C0"><INPUT TYPE=SUBMIT NAME="SEND" VALUE="Send Message"></TD>
  144.         <TD BGCOLOR="#C0C0C0" COLSPAN=2>
  145.             <% If ErrStr <> "" Then %>
  146.             <FONT COLOR="#FF0000"><B>Message was not sent due to the following error: <i><% = ErrStr %></I></B></FONT>
  147.             <% End If %>
  148.         </TD>
  149.     </TR>
  150. </FORM>
  151. </TABLE>
  152.  
  153. </TD>
  154.  
  155. </TABLE>
  156. </BASEFONT>
  157. </BODY>
  158. </HTML>
  159.