aspNetEmail Parameters

Discussion in 'Databases' started by westmiller, Feb 5, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I'm trying to insert a simple VB code sequence for a fixed email message to me whenever other users update a central database. The message is fixed and requires no variable parameters.
    This is my first shot at ASP email generation, so I'm having a difficult time just substituting the proper parameters to generate the email. I've found a few scripts, such as KB 10247, butI'm just looking for a few direct VB lines to include after my rs.update.

    A. Do I needto have a web.config file?
    B. Is the SMTPServer value = 'mail.mydomain.org'?
    C. What is the parameter for Server.CreateObject(to use aspNetEmail?
    D. Some scripts set Mailer.RemoteHost = SMTPServer - is that required?

    The other parameters are obvious, but I'm only looking for "quick and dirty" that works.

    Bill
     
  2. I'd recommend simply using System.Web.Mail instead of aspNetEMail. It should easily do what you want and you can skip the register directive for aspNetEMail.

    Here is sone code:

    dim mm as new System.Web.Mail.MailMessage
    mm.From = <from address>
    mm.To = <to address>
    mm.Subject = <subject>
    mm.BodyFormat = System.Web.Mail.MailFormat.Text (or System.Web.Mail.MailFormat.Text)
    mm.Body = <the text of your message here>
    System.Web.Mail.SmtpMail.SmtpServer = 'localhost' (use localhost for the SmtpServer even if you do decide to go with aspNetEMail)

    System.Web.Mail.SmtpMail.Send(mm)
     
  3. Your script looks like a universal resident send routine,
    which should be fine.
    If I want to use aspNetEmail for future enhancements,
    I'd better know the routine. Following is the code slice
    from the aspNetEmail site, with my substitutions ...
    which won't even load, much less execute:

    Dim msg As New aspNetEmail.EmailMessage()
    msg.Server = "mail.republicanliberty.org"
    msg.FromAddress = "[email protected]"
    msg.To = "[email protected]"
    msg.Subject = "Test aspNetEmail from email.asp"
    msg.Body = "This is a test email."
    If msg.Send() Then
    Response.Write("Message Sent.")
    Else
    Response.Write(("The following error occurred: " + msg.LastException().Message))
    End If

    What's wrong?

    Bill
     
  4. Here's where my ignorance comes in! [​IMG]


    If I copy it as it exists (with my email parameters), I just get "The Page Cannot be Displayed", even if I add some response.write lines. [​IMG]


    Since the primary code is apparently a subroutine (though it seems to get called on Page_Load), I'm assuming I need something to call the routine. I just don't know what "sender" or "e" variables to submit:


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


    Which is what prompted the A,B,C,D questions in my initial post.


    Bill
     
  5. The "asp" file extension (/sanford08/sy_email.asp, line 13) indicates you are using asp, not asp.net.

    The code I provided which uses System.Web.Mail.MailMessage requires asp.net.


    Also, aspNetEMail is an asp.net componenent.
     
  6. I tried your standard System.Web.Mail code:
    (The file ison the DiscountASP System, so I assume the syntax is valid).



    Microsoft VBScript compilation error '800a0401'
    Expected end of statement
    /sanford08/sy_email.asp, line 13 dim mm as new System.Web.Mail.MailMessage
    -------^
    [​IMG]
     
  7. >The code I provided which uses System.Web.Mail.MailMessage requires asp.net.

    So, there are no email functions available in standard ASP? [​IMG]
    I've got code fragments that use "SMTPsvg.Mailer" and
    "CDONTS.NewMail" as objects. Useless on DiscountASP?

    Bill
     
  8. Takeshi Eto

    Takeshi Eto DiscountASP.NET Staff

  9. > There is sample code for ASPMail and CDO.

    Thanks. Looks like that will work for me.
    I guesslike I'll have to learn the whole new dialect of asp.net
    for future implementations.

    I'm an old dog, but Ithink I can still learn some new tricks! [​IMG]

    Bill
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page