Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Emailing Code works fine in debug mode, BUT NOT when uploaded

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
.spider - 17 Jul 2007 14:02 GMT
Hi,
This code emails the contents of 'TextBox1' and 'TextBox3' to
rcv@domain.com.. this code seemed to be working fine in debug mode and
DID mail rcv@domain.com However when i uploaded the website to my
hosting account, my browser popped up and alertbox saying:
"Sys.WebForms.PageRequestServerManagerErrorException An unknown error
occured while processing the request on the server. The status code
returned from the server was : 500"

CODE
----------------------------
protected void ImageButton1_Click(object sender, ImageClickEventArgs
e)
   {
       if (Process(TextBox1.Text) == true)       //Checks if supplies
string is a valid email type or not
       {                                                         //
There was a good reason to do it server side as it was locking up
                                                                 //
other controls
           Label1.Text = null;
           //Create Mail Message Object with content that you want to
send with mail.
           System.Net.Mail.MailMessage MyMailMessage = new
System.Net.Mail.MailMessage("snd@gmail.com", "rcv@domain.com",
           "WebVisitor:" + DateTime.Now.ToString("MMMM dd yyyy"),
"email: " + TextBox1.Text + "\nquery: " + TextBox3.Text);

           MyMailMessage.IsBodyHtml = false;

           //Proper Authentication Details need to be passed when
sending email from gmail
           System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential("send@gmail.com", "password");

           //Smtp Mail server of Gmail is "smpt.gmail.com" and it
uses port no. 587
           System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

           //Enable SSL
           mailClient.EnableSsl = true;

           mailClient.UseDefaultCredentials = false;

           mailClient.Credentials = mailAuthentication;

           mailClient.Send(MyMailMessage);

           TextBox1.Text = null;
           TextBox3.Text = null;
       }
       else
       {
           Label1.Text = "is INVALID";
           TextBox1.Text = null;
       }
   }
----------------------------
bruce barker - 17 Jul 2007 15:59 GMT
check that port 587 is open from your hosting server.

-- bruce (sqlwork.com)

> Hi,
> This code emails the contents of 'TextBox1' and 'TextBox3' to
[quoted text clipped - 55 lines]
>     }
> ----------------------------
Juan T. Llibre - 17 Jul 2007 16:46 GMT
Try:

!> System.Net.Mail.MailMessage("snd", "rcv@domain.com",

instead of
!> System.Net.Mail.MailMessage("snd@gmail.com", "rcv@domain.com",

Also, you have to setup your Gmail account for POP3 access.
There's instructions for doing that at the Gmail site.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
> Hi,
> This code emails the contents of 'TextBox1' and 'TextBox3' to
[quoted text clipped - 55 lines]
>    }
> ----------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.