| | |
MailMessage Problems
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
Hey people , i am trying to send an email, but for some reason its just not sending ... please help me out , here's my code
this email sends via a CSV file that is imported to a datatable (dt)
C# Syntax (Toggle Plain Text)
// trying this block of code try { // Looping through the rows in the datatable foreach (DataRow Row in dt.Rows) { //declaring strings to hold the values string camp_code = Row["Campaign_Code"].ToString(); string camp_name = Row["Campaign_Name"].ToString(); string comapny_name = Row["company"].ToString(); string email_address = Row["email"].ToString(); //settind txtTo.text to the value in the email string variable txtTo.Text = email_address; // Declaring a new instance of a mail message MailMessage E_Mail_Message = new MailMessage(); //MailAddress MA = new MailAddress("info@place.co.za"); // Adding the To address to the mail message // The to address is = txtTo.Text E_Mail_Message.To.Add(new MailAddress(txtTo.Text)); // Setting the body of the email message // The body is = txtMessage.Text E_Mail_Message.Body = txtMessage.Text; // Setting the subject of the email message // The subject is = txtSubject.Text E_Mail_Message.Subject = txtSubject.Text; // Setting the from address of the email message // The from address is = txtFrom.Text E_Mail_Message.From = new MailAddress(txtFrom.Text); // Declaring an instance of a SMTP client SmtpClient SMTP = new SmtpClient("smtp.place.com", 25); if (CB_Authentication.Checked == true) { // Setting SMTP Default credentials to false SMTP.UseDefaultCredentials = false; // Adding new Credentials System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential(txtUsername.Text, txtPassword.Text); // setting smtp credentials to the new credentials SMTP.Credentials = theCredential; } if (cboPorts.Text == "SMTP") { SMTP.Port = 25; } if (cboPorts.Text == "POP") { SMTP.Port = 110; } if (cboPorts.Text == "FTP") { SMTP.Port = 21; } if (cboPorts.Text == "HTTP") { SMTP.Port = 80; } SMTP.Send(E_Mail_Message); txtTo.Text = ""; } } catch (Exception EX) { MessageBox.Show("Sorry it didnt work"); } }
this email sends via a CSV file that is imported to a datatable (dt)
Last edited by cVz; Dec 2nd, 2008 at 10:20 am.
Delphi & C# programmer deluxe...
•
•
•
•
That looks like a mass-mailing application...not sure I WANT to help, but does it just not work or are you getting an exception?
If you're getting an exception, what is it?
If it just "doesn't work", what debugging (to ensure you are getting the right parameters set) have you done?
thanks dude, it works, and you are right, mass mailing , not for spamming though...
Delphi & C# programmer deluxe...
![]() |
Similar Threads
- Sending mails...... (ASP.NET)
- Gridbag Layout Probelm [Code Included] (Java)
- I need a code for sending e-mail (C#)
Other Threads in the C# Forum
- Previous Thread: how to print "" in c#
- Next Thread: Portfolio program
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





