They are going from "login.aspx" to "contentpage.aspx" and I want the mail sent 
when they hit "contentpage.aspx" would that still be a post back? Logging in 
automatically sends the client to "contentpage.aspx" and nowhere else.

Also, how do I populate the "From", "Subject" and "Body" (Page viewed at 
DateTime) dynamically? I understand that it has to be pulled from the 
authentication cookie placed by the login.aspx page and matched to a dataset 
and I need to create a dataset for the "contentpage.aspx" but I'm not quite 
sure about the syntax of how to do it. 

In English I want to say "Get the userID from the cookie, then compare it to 
the dataset and pull "userID" and put it in the subject line, "Email" and put 
it in the From line and put a time/date in the message body and send 
automatically."

Thank you for the help.

Jeff
  ----- Original Message ----- 
  From: Dean Fiala 
  To: [email protected] 
  Sent: Monday, November 07, 2005 8:04 PM
  Subject: Re: [AspNetAnyQuestionIsOk] Re: Send Mail on Page Load


  Your basic idea is right, though your syntax is off.  You've embedded
  a function declaration in If..then block.  Also Yuo probably want to
  send you mail when the user posts back to the form, not when they view
  the page (you won't know who they are).

  I'd so something like this...
  Sub Page_Load()

  If Page.IsPostBack then
     If Login(username, pwd) = true then
       SendMail(your parms here )
     End if
  End if
  End Sub

    Public Function SendMail (By Val [To] As String
           ByVal Body As String, ByVal IsHTML As Boolean, _
           Optional ByVal SmtpServer As String = "domain.com") As
  Boolean
           Try
              Dim objMsg As New System.Web.Mail.MailMessage()
              SendMail = True
              With objMsg
                  .To = [To]
                  .From = From
                  .Subject = Subject
                  .Body = Body
                         .BodyFormat = IIf(IsHTML = False, _
              System.Web.Mail.MailFormat.Html, _
              System.Web.Mail.MailFormat.Text)
         End With
         System.Web.Mail.SmtpMail.SmtpServer = SmtpServer
         System.Web.Mail.SmtpMail.Send(objMsg)
     Catch
         SendMail = False
     End Try
  End Function



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to