使用组件实现邮件发送

  • 在安装了WinWebMail之后,您将可以利用WinWebMail组件在ASP页面中直接发送纯文本或是html格式的电子邮件(无需登录)。
  • 此ASP文件必须被放置于WebMail的虚拟目录之下时才可以调用成功,如果您需要在其他网站上使用此组件对外发信时,建议使用Post方式将数据传递到当前页面,再经由此页面发送出去。
  • 绿色部分是可变内容。
  • 深蓝色部分是为了防止系统Session超时可能引起发送失败而加入的内容。

  • <%@LANGUAGE = VBSCRIPT%>
    <html>
    <body>

    <%
    if IsEmpty(Application("em_MaxMPOP3")) and IsEmpty(Application("em_MaxSigns")) then
        dim mam
        set mam = server.createobject("easymail.AdminManager")

        tmp_num = 0
        do while tmp_num < 30
            mam.LoadExt

            if mam.IsLoadOK = true then
                Exit Do
            end if

            mam.Sleep 500
            tmp_num = tmp_num + 1
        loop

        if mam.IsLoadOK = true then
            Application("em_MaxMPOP3") = mam.MaxMPOP3
            Application("em_MaxSigns") = mam.MaxSigns
            Application("em_SystemAdmin") = LCase(mam.SystemAdmin)
            Application("em_EnableBBS") = mam.EnableBBS
            Application("em_Enable_SignHold") = mam.Enable_SignHold
            Application("em_Enable_FreeSign") = mam.Enable_FreeSign
            Application("em_Enable_SignWithDomainUser") = mam.Enable_SignWithDomainUser
            Application("em_Enable_SignNumberLimit") = mam.Enable_SignNumberLimit
            Application("em_SignNumberLimitDays") = mam.SignNumberLimitDays
            Application("em_Enable_ShareFolder") = mam.Enable_ShareFolder
            Application("em_Enable_SignEnglishName") = mam.Enable_SignEnglishName
            Application("em_LogPageKSize") = mam.LogPageKSize
            Application("em_TestAccounts") = LCase(mam.TestAccounts)
            Application("em_SignMode") = mam.SignMode
            Application("em_SignWaitDays") = mam.SignWaitDays
            Application("em_am_Name") = mam.am_Name
            Application("em_am_Accounts") = LCase(mam.am_Accounts)
            Application("em_AccountsAdmin") = LCase(mam.AccountsAdmin)
            Application("em_EnableEntAddress") = mam.Enable_Show_EntAddress
            Application("em_SpamAdmin") = LCase(mam.SpamAdmin)

            Application("em_EnableTrap") = mam.EnableTrap
            if mam.EnableTrap = true then
                Application("em_TrapMail") = mam.TrapMail
            end if
        end if

        set mam = nothing
    end if
    %>

    <%
    Dim mailsend
    Dim sender


    ' 发送帐号是 admin, 填写邮件系统内有效帐号名称
    sender = "admin"


    ' 创建MailSend对象
    Set mailsend = Server.CreateObject("easymail.MailSend")

    mailsend.CreateNew sender, "temp"


    ' 发信人名称
    mailsend.MailName = "系统管理员"

    ' 收件人邮件地址
    mailsend.EM_To = "admin@system.mail"

    mailsend.EM_Subject = "邮件主题"
    mailsend.EM_Text = "邮件正文内容!"

    ' ================== 需要发送html格式邮件时使用以下内容 ==================
    ' 输入html邮件内容
    'mailsend.EM_HTML_Text = "<html>请在此处输入html邮件内容...</html>"
    'mailsend.useRichEditer = true
    ' ========================================================================


    if mailsend.Send() = false then
        Response.Write "邮件发送失败!"
    else
        Response.Write "邮件发送成功!"
    end if


    Set mailsend = Nothing
    %>

    </body>
    </html>

如果有问题或者购买需求,请随时和我们保持联系