SUB SendEmail(strFrom, strTo, strSubject, strContent)
   
    DIM objMail, FSO, File
    DIM URL, conf, Flds, strIIS

    ' 서버의 iis 버전을 알아낸다.
    strIIS = Request.ServerVariables("SERVER_SOFTWARE")
    strIIS = Split(Trim(strIIS), "/")
   
    IF strIIS(1) = "5.0" THEN     ' windows2000 -> CDONTS.NewMail
        SET objMail = Server.CreateObject("CDONTS.NewMail")
        SET conf = Server.CreateObject("CDO.Configuration")
    
        '미리 저장된 이메일 샘플 파일을 읽어서 보낼경우
        ' URL = server.MapPath("email_sample.asp")
        ' SET FSO = Server.CreateObject("Scripting.FileSystemObject")
        ' SET File = FSO.openTextFile(URL,1)
        ' strContent = File.ReadAll
        ' File.close

        WITH objMail
        .FROM     = strFrom
        .To         = strTo
        .Subject = strSubject
        .BodyFormat = 0
        .MailFormat = 0
        .Body = strContent
        .Send
        END WITH
       
    ELSE   ' IIS6.0 window2003  -> CDO.Message
   
        SET objMail = Server.CreateObject("CDO.Message")
        SET conf = Server.CreateObject("CDO.Configuration")
        SET Flds = conf.Fields

        ' 메일 서버 세팅   
        Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" 'Mail Server Address or Domain or "localhost"
        Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  'SMTP Port
        Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1        'cdoSendUsingPort 1=내부, 2=외부 (외부 메일 서버 사용시 아래 정보들 반드시 있어야함.)
        Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\Inetpub\mailroot\Pickup"
'        Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
'        Flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = 메일 서버 계정 ID
'        Flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = 메일서버 계정 비밀번호
        Flds.Update

       '미리 저장된 이메일 샘플 파일을 읽어서 보낼경우
        ' URL = server.MapPath("email_sample.asp")
        ' SET FSO = Server.CreateObject("Scripting.FileSystemObject")
        ' SET File = FSO.openTextFile(URL,1)
        ' strContent = File.ReadAll
        ' File.close

        WITH objMail
            SET  .Configuration        = conf
            .MimeFormatted             = false
            .AutoGenerateTextBody  = false
            .FROM                         = strFrom
            .To                              = strTo
            .Subject                       = strSubject
            .HTMLBody                  = strContent
.BodyPart.Charset         ="ks_c_5601-1987"    '한글 깨질경우
.HTMLBodyPart.Charset="ks_c_5601-1987"     '한글 깨질경우
            .fields.update
            .Send
        END WITH
    END IF
    SET objMail = NOTHING
END SUB
반응형
function IsEmail( strEmail )
{
return (/^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.)+([0-9a-zA-Z-]+)([\.0-9a-zA-Z-])*$/.test( strEmail ) );
}
반응형

+ Recent posts