Professional Web Applications Themes

Problems with the SmtpMail.Send() method - ASP.NET General

Hello, I have created a simple code to send emails using the MailMessage class and the SmtpMail.Send() method: MailMessage mail = new MailMessage(); mail.From = com; // hard-coded mail.To = com; mail.Subject = "Test"; mail.Body = strMessage; mail.BodyFormat = MailFormat.Html; SmtpMail.Send(mail); It works fine as long as the mail.From address is hard-coded. When I changed the line to: string strEmail = txtEmail.Value; mail.From = strEmail; txtEmail is an HTML server-control: <input id="txtEmail" type="text" maxLength="40" size="20" name="txtEmail" runat="server"> the code stopped working. I mean it does not send emails and even does not throw any exception!!! Is there any possibility to ...

  1. #1

    Default Problems with the SmtpMail.Send() method

    Hello,

    I have created a simple code to send emails using the MailMessage class and
    the SmtpMail.Send() method:

    MailMessage mail = new MailMessage();
    mail.From = com; // hard-coded
    mail.To = com;
    mail.Subject = "Test";
    mail.Body = strMessage;
    mail.BodyFormat = MailFormat.Html;
    SmtpMail.Send(mail);

    It works fine as long as the mail.From address is hard-coded. When I changed
    the line to:
    string strEmail = txtEmail.Value;
    mail.From = strEmail;

    txtEmail is an HTML server-control:
    <input id="txtEmail" type="text" maxLength="40" size="20" name="txtEmail"
    runat="server">

    the code stopped working. I mean it does not send emails and even does not
    throw any exception!!!
    Is there any possibility to check the status of a sent message? Does
    SmtpMail have any "error" property to check if the email has been sent
    properly?
    If I could not be sure that the message has been sent properly the
    SmtpMail.Send() method would be of no use.

    Please advice what to do. Should I use SmtpMail.Send() or maybe another
    method?

    Thanks for any hints,
    Leszek Taratuta



    Leszek Guest

  2. #2

    Default Re: Problems with the SmtpMail.Send() method

    Leszek,

    Is txtEmail.Value the equivalent of txtEmail.Text in VB.Net?

    Try using: txtEmail.Text.ToString instead.

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "Leszek" <com> wrote in message
    news:O$0%phx.gbl... 
    and 
    changed 


    S. Guest

  3. #3

    Default Re: Problems with the SmtpMail.Send() method

    Some mail servers are configured to perform DNS lookup to verify the domain
    name of the from e-mail address. May be this is your problem.


    "Leszek" <com> wrote in message
    news:O$0#phx.gbl... 
    and 
    changed 


    Sherif Guest

Similar Threads

  1. Replies: 2
    Last Post: July 21st, 02:01 PM
  2. Send in POST method
    By max4o@magic.g00net.org in forum Perl / CGI
    Replies: 2
    Last Post: December 4th, 11:11 AM
  3. where to get jMail.SMTPMail
    By Aaron Bertrand - MVP in forum ASP Components
    Replies: 4
    Last Post: November 5th, 12:14 AM
  4. Use of SmtpMail to Send Mail Outside Domain
    By Leonard in forum ASP.NET General
    Replies: 2
    Last Post: August 20th, 12:35 PM
  5. How can I run the send page method
    By Peter McMahon [MVP] in forum ASP.NET General
    Replies: 0
    Last Post: July 1st, 09:49 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139