Search The ForumSearch   RegisterRegister  LoginLogin

MailBee SMTP

 AfterLogic Forum : MailBee SMTP
Subject Topic: ASP SMTP Component Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Guests
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 19 October 2004 at 7:14pm | IP Logged Quote Guests

Hi:
I installed the SMTP Component for working with ASP pages.
I'd like to send by email a resultant ASP page using a root reference from my website and not physical address. Can you help me about that?

...
objSMTP.Subject = "Datum S.A. - Servicios de Informacion"

objSMTP.ImportBodyText "F:\Intepub\wwwroot\WebDatumDC\sms\DatumCheckSMSemail.asp", True

objSMTP.Send
...

I want to use something like that:

objSMTP.ImportBodyText "sms\DatumCheckSMSemail.asp", True

With this way, I can to send variable date in the ASP Page.
Back to Top View Guests's Profile Search for other posts by Guests
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 20 October 2004 at 7:13am | IP Logged Quote Alex

It seems you're developing some sort of automated mailing where the same email is sent to different addresses with customization of certain fields. E.g. page layout is the same, while data values are different (probably taken from database). For this purpose, mail merge technology is optimal for both sending performance and simplicity of page layout modifications.

Mail merge assumes you have the layout of your page with placeholders instead of real values. In fact, your existing ASP page is already a sort of such layout. Let's assume the ASP page you want to send looks like below:

' Mail.asp
<html>
From:<%=strSender%> <br>
To:<%=strRecipient%> <br>
Subject: <%=short_txt%>

<p>
Here is a diagram: <br>
<%=diagram_html%>
</p>
</html>

Also, let's assume we have database table containing all values used for strSender, short_text, etc.
Now, send the ASP page to all recipients taking values from database table. For shorter code, I omitted connection to database becuase it's not a key part of the example. In the code below, rsEmails is already opened database table.

' Omitted: connect to database, open table and load it into rsEmails recordset object

Set objSMTP = Server.CreateObject("MailBee.SMTP")
objSMTP.LicenseKey = "put your license key here"
objSMTP.ServerName = "localhost"
If objSMTP.Connect

Do While Not rsEmails.EOF
    objSMTP.FromAddr = rsEmails("from")
    objSMTP.ToAddr = rsEmails("to")
    objSMTP.Subject = rsEmails("short_text")

    ' The most interesting part: get message from file,
    ' and then replace variables with real values
    objSMTP.ImportBodyText "C:\path_to_file\Mail.asp", 1
    objSMTP.BodyText = Replace(objSMTP.BodyText, _
      "<%=strSender%>", rsEmails("from"))
    objSMTP.BodyText = Replace(objSMTP.BodyText, _
      "<%=strRecipient%> ", rsEmails("to"))
    objSMTP.BodyText = Replace(objSMTP.BodyText, _
      "<%=short_text%>", rsEmails("short_text"))
    objSMTP.BodyText = Replace(objSMTP.BodyText, _
      "<%=diagram_html%> ", rsEmails("diagram_html"))

    If Not objSMTP.Send Then
      Response.Write _
        "Error! Check ServerResponse and ErrCode"
      Response.End
    End If

    ' Once the message is sent, we need
    ' to clear it before sending next message
    objSMTP.ResetMessage

    rsEmails.MoveNext
Wend

objSMTP.Disconnect
End If

The code above is simplified and shows the idea only. You can find complete examples of mail merge at "Mail merge and bulk e-mail" topics of "Code Samples/Sending e-mails (SMTP)" section in MailBee Objects help file.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide