IIS の サービスの Simple Mail Transfer Protocol (SMTP) を使用して 自分のマシンから外部へメール送信する為に、プロパティの設定を行います 以下のコードを IIS で表示してメールを送信します 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <% Call Response.AddHeader( "Content-Type", "text/html; Charset=shift_jis" ) Response.ExpiresAbsolute=#May 31,2000 23:59:59# Dim strMessage ' ********************************************************** ' MODEL ' ********************************************************** function SendMail() if Trim( Request.Form( "Body" ) ) = "" then strMessage = "本文を入力して下さい" end if if Trim( Request.Form( "From" ) ) = "" then strMessage = "送信者を入力して下さい" end if if Trim( Request.Form( "Subject" ) ) = "" then strMessage = "件名を入力して下さい" end if if Trim( Request.Form( "To" ) ) = "" then strMessage = "宛先を入力して下さい" end if if strMessage <> "" then Exit Function end if Set Cdo = Server.CreateObject("CDO.Message") Cdo.From = Request.Form( "From" ) Cdo.To = Request.Form( "To" ) Cdo.Subject = Request.Form( "Subject" ) Cdo.Textbody = Request.Form( "Body" ) Cdo.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = _ 2 Cdo.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ "localhost" Cdo.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = _ 25 Cdo.Configuration.Fields.Update on error resume next Cdo.Send if Err.Number <> 0 then strMessage = Err.Description else strMessage = "送信が完了しました" end if on error goto 0 end function ' ********************************************************** ' CONTROL ' ********************************************************** if Request.Form( "send" ) = "送信" then Call SendMail() end if %> <!-- ********************************************************** VIEW *********************************************************** --> <FORM method=POST> 宛先 <INPUT type=text name=To size=100 value="<%= Request.Form( "To" ) %>"><br> 件名 <INPUT type=text name=Subject size=100 value="<%= Request.Form( "Subject" ) %>"><br> 送信者 <INPUT type=text name=From size=100 value="<%= Request.Form( "From" ) %>"><br> <br> <TEXTAREA cols=80 rows=20 name=Body ><%= Request.Form( "Body" ) %></TEXTAREA> <INPUT type=submit name=send value="送信"> </FORM> <HR> <%= strMessage %>
<% Call Response.AddHeader( "Content-Type", "text/html; Charset=shift_jis" ) Response.ExpiresAbsolute=#May 31,2000 23:59:59# Dim strMessage ' ********************************************************** ' MODEL ' ********************************************************** function SendMail() if Trim( Request.Form( "Body" ) ) = "" then strMessage = "本文を入力して下さい" end if if Trim( Request.Form( "From" ) ) = "" then strMessage = "送信者を入力して下さい" end if if Trim( Request.Form( "Subject" ) ) = "" then strMessage = "件名を入力して下さい" end if if Trim( Request.Form( "To" ) ) = "" then strMessage = "宛先を入力して下さい" end if if strMessage <> "" then Exit Function end if Set Cdo = Server.CreateObject("CDO.Message") Cdo.From = Request.Form( "From" ) Cdo.To = Request.Form( "To" ) Cdo.Subject = Request.Form( "Subject" ) Cdo.Textbody = Request.Form( "Body" ) Cdo.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = _ 2 Cdo.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ "localhost" Cdo.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = _ 25 Cdo.Configuration.Fields.Update on error resume next Cdo.Send if Err.Number <> 0 then strMessage = Err.Description else strMessage = "送信が完了しました" end if on error goto 0 end function ' ********************************************************** ' CONTROL ' ********************************************************** if Request.Form( "send" ) = "送信" then Call SendMail() end if %> <!-- ********************************************************** VIEW *********************************************************** --> <FORM method=POST> 宛先 <INPUT type=text name=To size=100 value="<%= Request.Form( "To" ) %>"><br> 件名 <INPUT type=text name=Subject size=100 value="<%= Request.Form( "Subject" ) %>"><br> 送信者 <INPUT type=text name=From size=100 value="<%= Request.Form( "From" ) %>"><br> <br> <TEXTAREA cols=80 rows=20 name=Body ><%= Request.Form( "Body" ) %></TEXTAREA> <INPUT type=submit name=send value="送信"> </FORM> <HR> <%= strMessage %>