Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2006, 01:49 PM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ansalon5
Default sending email

I am in the process of converting an old asp form using Visual Studio 2003 that was originally written using the program ASP Mail.

I have been able to convert over most of the web form without a problem but where I am getting stuck is when I try to send the message I get no errors(compile or runtime) yet no message is sent. The second piece to this puzzle is that after the email gets sent a confirmation screen is shown with the results of the previous web form.

Any help would be greatly appreciated.

ansalon5

 
Old June 19th, 2006, 07:44 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I am not familiar with the ASP Mail Component as I use the System.Web.Mail class (read as CDONTS replacement)to facilitate sending of mail from the web. (I use it to generate error emails that are sent to my account when an exception is thrown in my applications)

                Dim mail As New MailMessage
                Dim strErrorMessage As String
                mail.To = ConfigurationSettings.AppSettings("errorEmail")
                mail.From = "Information Database"
                mail.Subject = "Error In Information Database Generated By: " & User.Identity.Name
                mail.Priority = MailPriority.High
                mail.BodyFormat = MailFormat.Text
                mail.Body = strMessage
                SmtpMail.SmtpServer = [Your Mail Server here]
                SmtpMail.Send(mail)
                Response.Redirect("../client_error.aspx")

Let me explain this code real quick ConfigurationSettings.AppSettings("errorEmail") pulls the email address the mail should be sent to from the web.config file

This line User.Identity.Name tells me the domain user the caused the error

The variable strMessage that makes up the body of the email contains my stack trace, error message, page it occured on, etc. (Obviously you could add in the fields of your form to make up the message body.)

Hope this helps.

"The one language all programmers understand is profanity."
 
Old June 27th, 2006, 01:34 PM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ansalon5
Default

Thanks for the reply. I have all of that formatting down as far as formatting of the message. The part that I am getting caught up on I think is the mail.to because I am calling a function.

In the function I see what option was selected from another drop down list on the form and then I just create a string with the email addresses concatinated with a ; if there is more than one. I think I am getting no message because I might be passing the wrong value. Unfortunately I don't have access to my code now because I'm at home and my project is at work but I will post the code snippit when I get to work on Monday.

ansalon5

Private Sub illMATC()
        Dim strMATC As String
        Dim strPickUp As String = lstPickup.SelectedValue
        Dim strCampus As String
        Dim strStatus As String = lstStatus.SelectedValue
        Dim strEmail_Address As String

        Dim strFullName As String = Name() 'txtName.Text
        Dim strPhone As String = Phone() 'txtPhone.Text
        Dim strEmail As String = Email() 'txtEmail.Text
        Dim strPeriodicalTitle As String = Periodical() 'txtPedTitle.Text
        Dim strArticleTitle As String = Article() 'txtArticleTitle.Text
        Dim strAuthor As String = Author() 'txtAuthor.Text
        Dim strPubDate As String = Published() 'txtPubDate.Text
        Dim strVolume As String = Volume() 'txtVol.Text
        Dim strPages As String = NumPages() 'txtPages.Text
        Dim strDateNeeded As String = WhenNeeded() 'txtNeeded.Text
        Dim strSubject As String = "I.L.L. Request"

    End Sub

    Private Sub CreateMessage(ByVal sender As System.Object, ByVal e As System.EventArgs, ByVal strFullName As String, ByVal strPhone As String, ByVal strEmail As String, ByVal strStatus As String, ByVal strPeriodicalTitle As String, ByVal strArticleTitle As String, ByVal strAuthor As String, ByVal strPubDate As String, ByVal strVolume As String, ByVal strPages As String, ByVal strDateNeeded As String, ByVal strPickUp As String, ByVal strEmail_Address As String, ByVal strSubject As String, ByVal strCampus As String)
        Dim strTo As String = getEmpName(strEmail_Address, strCampus)
        Dim MM As New System.Web.Mail.MailMessage ' Creates a new mail message
        Dim message As System.Web.Mail.SmtpMail

        Try
            MM.Subject = strSubject
            MM.To = strTo
            MM.BodyFormat = MailFormat.Html ' Indicate Email is sent in HTML format.
            MM.Priority = MailPriority.Normal
            message.SmtpServer = "mail.matcmadison.edu"

            txtMsgBody.Text = _
            "<html>" & Chr(13) & Chr(10) & _
            "<body bgcolor='#FFFFFF'>" & Chr(13) & Chr(10) & _
            "<table>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>FullName:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Name() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>Phone:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Phone() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>Email:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Phone() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>Status:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Status() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>PeriodicalTitle:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Periodical() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>ArticleTitle:&nbsp;&nbsp</b></div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Article() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>Author:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Author() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>PubDate:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Published() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>Volume:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Volume() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>Pages:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & NumPages() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>DateNeeded:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & WhenNeeded() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            " <tr>" & Chr(13) & Chr(10) & _
            " <td><div align='right'><b>PickUp:&nbsp;&nbsp</b> </div></td>" & Chr(13) & Chr(10) & _
            " <td><div align='left'> " & Campus() & "</div></td>" & Chr(13) & Chr(10) & _
            " </tr>" & Chr(13) & Chr(10) & _
            "</table>"
            MM.Body = txtMsgBody.Text
            message.Send(MM)
        Catch ex As Exception
            Response.Write("Error encountered: " & ex.ToString)
        End Try
    End Sub

 Private Function getEmpName(ByVal strEmail_Address As String, ByVal strCampus As String) As String
        Dim strTo As String

        If strCampus = "Downtown" Then
            strEmail_Address = "[email protected]"
            'strEmail_Address = "[email protected]"
            strTo = strEmail_Address
        ElseIf strCampus = "Fort Atkinson" Then
            strEmail_Address = "[email protected]"
            strTo = strEmail_Address
            strEmail_Address = "[email protected]"
            strTo += "; " & strEmail_Address
            strEmail_Address = "[email protected]"
            strTo += "; " & strEmail_Address
        ElseIf strCampus = "Portage" Then
            strEmail_Address = "[email protected]"
            strTo = strEmail_Address
            strEmail_Address = "[email protected]"
            strTo += "; " & strEmail_Address
        ElseIf strCampus = "Reedsburg" Then
            strEmail_Address = "[email protected]"
            strTo = strEmail_Address
            strEmail_Address = "[email protected]"
            strTo += "; " & strEmail_Address
        ElseIf strCampus = "Truax" Then
            strEmail_Address = "[email protected]"
            strTo = strEmail_Address
            strEmail_Address = "[email protected]"
            strTo += "; " & strEmail_Address
        ElseIf strCampus = "Watertown" Then
            strEmail_Address = "[email protected]"
            strTo = strEmail_Address
            strEmail_Address = "[email protected]"
            strTo += "; " & strEmail_Address
        End If
        Return strTo

    End Function





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending EMAIL charleshua BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 16 September 3rd, 2008 12:27 AM
Sending email maitias C# 2005 2 February 17th, 2006 11:24 AM
sending email keyvanjan Classic ASP Components 1 May 9th, 2005 05:56 PM
email sending msrnivas .NET Web Services 6 June 26th, 2004 06:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.