Question

For about a year now, I've had problems trying to send and receive email programmatically using Visual C#. Not a single example out of hundreds that I've found on the web have ever worked. And no, I don't just copy and paste. I study the code, and modify/add/remove as needed.

Can somebody PLEASE help me sort this out. I'm trying to finish what should've been a simple program that I started making last year, and it's proving to be almost impossible for me to figure out.

I honestly don't know what the heck to do anymore. The documentation provides no useful information to me because none of it has ever worked. I've given sample code to others to use, and it works for them - but not me! How does that work?

I don't know if SENDING mail is dependent upon what security/firewall settings my computer has or not. But just in-case, I have gone so far as to completely turn off all security and firewall settings temporarily just to see if it would send an email.

I don't have code for it anymore since I have only just started trying to do this thing again and I would really appreciate it if somebody could assist me in getting this working.

So, all I am trying to do is:

Create a simple Form with 2 buttons and a textbox. (done, ofcourse) button1 checks for email (but only displays the subject and sender in a messagebox, does not download the message) button2 sends the contents of textBox1 to "username@bluebottle.com"

My server settings are:

Username    username@bluebottle.com
Password    ***********
IMAP/POP Server (Incoming):     mail.bluebottle.com
SMTP Server     (Outgoing):     mail.bluebottle.com

SMTP should be port 25, 26 or 587
POP3 should be port 110, using SSL 995
IMAP should be port 143, using SSL 993


Thanks for taking the time to read. If I haven't explained anything clearly please say so and I will try to make more sense out of it for you.

Was it helpful?

Solution

Never mind. I just figured it out for myself. It's a simple as 123! or is it ABC? I forget how it goes. Any how, incase anybody's interested or needs to know how to send e-mail in C#, this is what worked for ME:


string Sender     = "username@domain.com";

string Username   = "username";
string Password   = "********";

string Recipient  = "username@domain.com";

string Subject    = "Enter subject here.";
string Message    = "Enter message here.";

string Host       = "mail.server.com";
int Port          = 26;

using(MailMessage Mail = 
      new MailMessage(
      Sender,
      Recipient))
using (SmtpClient SmtpMail =
       new SmtpClient(
       Host,
       Port))
{
  Mail.Subject = Subject;
  Mail.Body    = Message;

  SmtpMail.EnableSsl = true;

  SmtpMail.Credentials =
        new System.Net.NetworkCredential(
        Username,
        Password);

  SmtpMail.Send(Mail);
}


Please note that the following using directive needs to be declared at the top of the document:

using System.Net.Mail;

Edit: Using Pattern docos: http://msdn.microsoft.com/en-us/library/yh598w02(VS.71).aspx

OTHER TIPS

Since this year Microsoft made pop3 and SMTP support available to all Hotmail users.

  • POP3 Server: pop3.live.com (port 995)
  • SMTP Server: smtp.live.com (port 25) {Note: If port 25 has been blocked in your network or by your ISP, you can set SMTP port to 587 with TLS or SSL Encryption depending on the client in use}

More info: http://windowslivehelp.com/solutions/settings/archive/2009/01/06/send-and-receive-windows-live-hotmail-emails-from-a-mail-client.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top