Results 1 to 3 of 3

Thread: Determine if an email message was sent

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    68

    Determine if an email message was sent

    I am creating a webform to send an email message using the System.Web.Mail Namespace. When the user clicks the submit button and the message is actually sent I want to redirect them to a confirmation page letting them know the message was sent succesfly.

    How can I determine if the message was sent succesfly.

    Here is the code I have so far

    Code:
        Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    
    
            If (Page.IsValid) Then
    
                Dim newMail As New MailMessage
    
                Try
    
                    newMail.From = txtSendersEmailAddress.Text
                    newMail.From = txtSenderName.Text
                    newMail.Subject = ddlQueryType.SelectedValue + " " + txtSubject.Text
                    newMail.To = "[email protected]"
                    newMail.BodyFormat = MailFormat.Text
                    newMail.Body = newMail.From + newMail.Subject + txtMessage.Text
                    SmtpMail.SmtpServer = "your.smtpserver.net.net"
                    SmtpMail.Send(newMail)
    
              Catch ex As Exception
    
                Finally
    
                    newMail = Nothing
    
                End Try
    
            End If

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Determine if an email message was sent

    if the email send fails... an exception should be thrown... so if you check for the exception (which you are doing) then you should be able to vary the output page from pass or fail simply by catching the error...

    you may want to look at the MailMessage object on MSDN to see any specific errors it might throw if you want to determine the cause of the failure...

  3. #3
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374

    Re: Determine if an email message was sent

    Is it possible to send a request for receipt of email using the MailMessage object?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width