Rectangle 27 3

try
     {
        MailMessage mail = new MailMessage();     //using System.Net.Mail namespace
        mail.To.Add("xyz@yahoo.com");             //Enter reciever's email address
        mail.From = new MailAddress("abc@gmail.com");  //Enter sender's email address
        mail.Subject = "Testing mail...";
        mail.Body = @"Lets-code ! Lets-code to make it simpler";
        mail.IsBodyHtml = true;                  //Body of mail supports html tags
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.Port = 587;
        smtp.Credentials = new System.Net.NetworkCredential("abc@gmail.com", "pwd");
        // Your gmail username and password   
        smtp.EnableSsl = true;            //Gmail uses a encrypted connection
        smtp.Send(mail);
        Response.Write("Mail Sent Successfully");
    }

catch(Exception ex)
    {  
        Response.Write(ex.Message);
    }

I tried your code as well with the firewall disabled and I still get the same error message, this appears to be a machine specific issue:(

Sending emails with Gmail and C#/VB.Net no longer works - Stack Overfl...

vb.net email gmail
Rectangle 27 9

For sending mail with attachment using php mail().Try this code:

<?php

 //If there is no error, send the email
 if(isset($_POST['ur_submit_button_name'])) {
  $EmailTo = "Me@here.com";
  $EmailFrom = "You@There.com";
  $EmailSubject = "The Email Subject";


  $separator = md5(time());

  // carriage return type (we use a PHP end of line constant)
  $eol = PHP_EOL;

  // attachment name
  $filename = "ip.zip";//store that zip file in ur root directory
  $attachment = chunk_split(base64_encode(file_get_contents('ip.zip')));

  // main header
  $headers  = "From: ".$from.$eol;
  $headers .= "MIME-Version: 1.0".$eol; 
  $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";

  // no more headers after this, we start the body! //

  $body = "--".$separator.$eol;
  $body .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
  $body .= "This is a MIME encoded message.".$eol;

  // message
  $body .= "--".$separator.$eol;
  $body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
  $body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  $body .= $message.$eol;

  // attachment
  $body .= "--".$separator.$eol;
  $body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; 
  $body .= "Content-Transfer-Encoding: base64".$eol;
  $body .= "Content-Disposition: attachment".$eol.$eol;
  $body .= $attachment.$eol;
  $body .= "--".$separator."--";

  // send message
  if (mail($to, $subject, $body, $headers)) {
  $mail_sent=true;
  echo "mail sent";
  } else {
  $mail_sent=false;
  echo "Error,Mail not sent";

 }
}

?>

Perfect code work like a charm

mail not send what we have to do .?

PHP Sending Emails with File Attachments - Email Not Sending At All - ...

email attachment email-attachments php
Rectangle 27 22

Just Go here : Less secure apps , Log on using your Email and Password which use for sending mail in your c# code , and choose Turn On.

public string sendit(string ReciverMail)
{
    MailMessage msg = new MailMessage();

    msg.From = new MailAddress("YourMail@gmail.com");
    msg.To.Add(ReciverMail);
    msg.Subject = "Hello world! " + DateTime.Now.ToString();
    msg.Body = "hi to you ... :)";
    SmtpClient client = new SmtpClient();
    client.UseDefaultCredentials = true;
    client.Host = "smtp.gmail.com";
    client.Port = 587;
    client.EnableSsl = true;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.Credentials = new NetworkCredential("YourMail@gmail.com", "YourPassword");
    client.Timeout = 20000;
    try
    {
       client.Send(msg);
        return "Mail has been successfully sent!";
    }
    catch (Exception ex)
    {
        return "Fail Has error" + ex.Message;
    }
    finally
    {
       msg.Dispose();
    }
}

If the above code don't work , try to change it like the following code :

SmtpClient client = new SmtpClient();
    client.Host = "smtp.gmail.com";
    client.Port = 587;
    client.EnableSsl = true;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false;
    client.Credentials = new NetworkCredential("YourMail@gmail.com", "YourPassword");

I've already tried both of those things and it still doesn't work.

smtp.UseDefaultCredentials = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("myemail@gmail.com", "mypassword");

Yes, I think default credentials need to be false and that line does have to be before the other one.

Both of them works for me . I will comment it in my answer.

smtp - How to send an e-mail with C# through Gmail - Stack Overflow

c# smtp gmail smtpclient
Rectangle 27 12

If gmail doesn't fail miserably, you have no way to suppress this warning. Google is in control of both accounts and therefore knows, that this mail wasn't send by fred using their infrastructure. There was used some third party infrastructure (yours) and this is all this warning is about. You can set an arbitrary email address as "from" and Google has no knowledge if this is legitimate use (if fred really wrote the message). Anyone could have written that message. Normally fred would use Googles infrastructure to send mails and then they would know its him.

A cleaner solution would be to put your email address ("noreply@company.com") as from header (that would be honest) and set fred@gmail.com as reply-to header (so he gets the replies).

email - Avoid Gmail's "This message may not have been sent by" using s...

email gmail
Rectangle 27 49

Great question. Email deliverability (the likelihood that messages will be delivered to the inbox) depends on many different factors. It is a joint responsibility both of the platform you're using (in this case, you mention Amazon SES) and your particular sending program. Depending on whom you're sending to and what sort of inbound mail protection is in place, you will face obstacles with your email delivery if you send mail that generates recipient complaints (aka, "This is Spam" button clicks), bounces for invalid addresses, content that has spammy fingerprints, and are sending to inactive but existing addresses that could actually be spamtraps. ISPs' mission is to protect their recipients from spam, although your definition of spam and theirs can vary. At the end of the day, it's up to you to ensure you're sending email recipients want and that you're quickly removing sending to those recipients who don't want it.

Amazon SES has IP space setup specifically tailored for outbound email based on ISP (e.g., Gmail, Yahoo, etc.) requirements. We've also rolled out several features that make it dead simple to: authenticate your email Easy DKIM, test your email to ensure you have the proper bounce and complaint handling (Mailbox Simulator) and can get at ISP feedback quickly and easily through Amazon Simple Notification Service (Bounce and Complaint Notifications).

Also, we've put together a whitepaper on sending best practices we recommend. Our blog gets updated frequently and often discusses topics which will impact deliverbility. Finally, we have a resources section that offers 3rd party providers that can assist you in more detail if you're still wondering what steps to take.

We want each of customers to be successful and have the highest deliverability possible. If you find us lacking in any resources or need additional features or data that you can't currently get, I'd love to hear about it so we can make Amazon SES better.

For your particular use case, I would suggest heading over to the Amazon SES so we can troubleshoot together. Pls provide specific details about your situation so we can dig into this. Answers to these questions will help us investigate:

  • What type of email are you sending?
  • Do you have a sample of a message we can review?
  • What are you doing with bounces and complaints?
  • How do you know you're being delivered to the spam folder and how often does it occur?
  • Have you checked your content against widely available and free services such as mail-tester.com?

To see the Amazon SES blog, tech documentation, best practices whitepaper, customer forum, and other service centric stuff, pls visit: http://aws.amazon.com/ses/

To see our resources page (also included on the Amazon SES page but a bit further down), visit: http://aws.amazon.com/ses/resources/

P.S. I originally had this answer chock full of links for easy navigation but stackoverlfow stripped them due to spam control measures. The irony!

Chris, Amazon SES definitely does have a problem with spam - see my answer.

Chris, I have AWS SES account and have 10 users in it. If one of the user is sending huge spam emails then are you going to block that one verified user or my entire account?

I am using development, only sending emails to my own accounts, and still, hotmail and yahoo auto send the emails to SPAM folders. I have 9/10 ranking on mail-tester. I have set up DKIM and spf. What else can I do?

Amazon SES mails as spams - Stack Overflow

amazon-web-services amazon-ses
Rectangle 27 13

If you're not using 2 Factor Authentication

as per:

In this case you would use your normal email and password to connect.

You need to create an app specific password for your application. Follow these steps:

  • in the top right corner click on your profile icon and select 'My Account'
  • Click on 'Sign in & Security'
  • Scroll down the 'Sign in & Security' page a bit and there is a section called 'App Passwords' Click on that.
  • You should see a dropdown labelled 'Select App'. Select Mail.
  • For the 'on my device' dropdown select 'Other' and type in commandline or whatever you want to call the app.

Click 'Generate'. A password will be generated. Copy that password and replace the password you were using in your options hash with the generated password:

Well, it looks like I'm out of luck: "The setting you are looking for is not available for your account.".

email - Ruby sending mail via gmail smtp - Stack Overflow

ruby email
Rectangle 27 12

using System.Net.Mail;
MailMessage sendmsg = new MailMessage(SendersAddress, ReceiversAddress, subject, body); 
SmtpClient client = new SmtpClient("smtp.gmail.com");

client.Port = Convert.ToInt16("587");
client.Credentials = new System.Net.NetworkCredential("mail-id@gmail.com","password");
client.EnableSsl = true;

client.Send(sendmsg);

c# - Sending email in .NET through Gmail - Stack Overflow

c# .net email smtp gmail
Rectangle 27 12

using System.Net.Mail;
MailMessage sendmsg = new MailMessage(SendersAddress, ReceiversAddress, subject, body); 
SmtpClient client = new SmtpClient("smtp.gmail.com");

client.Port = Convert.ToInt16("587");
client.Credentials = new System.Net.NetworkCredential("mail-id@gmail.com","password");
client.EnableSsl = true;

client.Send(sendmsg);

c# - Sending email in .NET through Gmail - Stack Overflow

c# .net email smtp gmail
Rectangle 27 12

using System.Net.Mail;
MailMessage sendmsg = new MailMessage(SendersAddress, ReceiversAddress, subject, body); 
SmtpClient client = new SmtpClient("smtp.gmail.com");

client.Port = Convert.ToInt16("587");
client.Credentials = new System.Net.NetworkCredential("mail-id@gmail.com","password");
client.EnableSsl = true;

client.Send(sendmsg);

c# - Sending email in .NET through Gmail - Stack Overflow

c# .net email smtp gmail
Rectangle 27 2

I'd recommend using a smarthost, e.g. your provider's email server, and forward over it. That is, configure your local mail server (in Debian exim is the default, and I guess it's the same for Ubuntu) to use a smarthost for mail delivery and configure it for rewriting such that all mail from your system is locally forwarded to the accounts of the people dealing with your MySQL slaves and these people are aliased to external addresses.

This can be done via the /etc/aliases file, if I remember correctly.

email - Send mail from a BASH Script and how to configure mail servers...

bash email smtp sendmail mail-server
Rectangle 27 8

Have you tried using the System.Net.Mail functions to send mail to the email corresponding to the phone number?

The user can have the mobiles with any providers. It may be Virgin, T-Mobile, AT & T. I should be able to send SMS to the users with regardless of their providers. So i am waiting for a better solution to use a Library or Gateway.

You could always ask the user for the name of their carrier. I believe this is why most places offering SMS services ask for it.

So frigging easy and useful. brb spamming millions of numbers.

The list of SMS gateways has been moved to: en.wikipedia.org/wiki/

SMS Library in C# - Stack Overflow

c# sms gateway
Rectangle 27 31

var mailer = require("nodemailer");

// Use Smtp Protocol to send Email
var smtpTransport = mailer.createTransport("SMTP",{
    service: "Gmail",
    auth: {
        user: "gmail_id@gmail.com",
        pass: "gmail_password"
    }
});

var mail = {
    from: "Yashwant Chavan <from@gmail.com>",
    to: "to@gmail.com",
    subject: "Send Email Using Node.js",
    text: "Node.js New world for me",
    html: "<b>Node.js New world for me</b>"
}

smtpTransport.sendMail(mail, function(error, response){
    if(error){
        console.log(error);
    }else{
        console.log("Message sent: " + response.message);
    }

    smtpTransport.close();
});

I found Nodemailer way easier to use than node-email-templates. Maybe it's because I was just trying to send basic plaintext/basic html email, but I found node-email-templates needed way more setting up, whereas Nodemailer was up and running in literally 2 minutes.

Other than gmail ? How can we configure for our own smtp server ?

Sending emails in Node.js? - Stack Overflow

node.js email-integration
Rectangle 27 8

To followup on jon's reply, here's an example of sending a mail using simple-java-mail.

The idea is that you don't need to know about all the technical (nested) parts that make up an email. In that sense it's a lot like Apache's commons-email, except that Simple Java Mail is a little bit more straightforward than Apache's mailing API when dealing with attachments and embedded images. Spring's mailing facility works as well but is a bit awkward in use (for example it requires an anonymous innerclass) and ofcourse you need to a dependency on Spring which gets you much more than just a simple mailing library, since it its base it was designed to be an IOC solution.

Simple Java Mail btw is a wrapper around the JavaMail API.

final Email email = new Email();

email.setFromAddress("lollypop", "lolly.pop@somemail.com"); 
email.setSubject("hey");
email.addRecipient("C. Cane", "candycane@candyshop.org", RecipientType.TO);
email.addRecipient("C. Bo", "chocobo@candyshop.org", RecipientType.BCC); 
email.setText("We should meet up! ;)"); 
email.setTextHTML("<img src='cid:wink1'><b>We should meet up!</b><img src='cid:wink2'>");

// embed images and include downloadable attachments 
email.addEmbeddedImage("wink1", imageByteArray, "image/png");
email.addEmbeddedImage("wink2", imageDatesource); 
email.addAttachment("invitation", pdfByteArray, "application/pdf");
email.addAttachment("dresscode", odfDatasource);

new Mailer("smtp.host.com", 25, "username", "password").sendMail(email);
// or alternatively, pass in your own traditional MailSession object.
new Mailer(preconfiguredMailSession).sendMail(email);

email - How do I send an e-mail in Java? - Stack Overflow

java email tomcat servlets
Rectangle 27 2

Rails or any gem wont provide this out of the box. You have to check with the mail provider you are using to send the email.

For example you may use Sendgrid or Postmark for sending your emails, postmark has an api via which you can track the bounce also hook it your app to update the status of the emails.

Postmark gem has good utility methods to interact with postmark api and deduce the bounces-reports, etc

Sending mails in Rails 4.2.0 and detect bounces - Stack Overflow

ruby-on-rails ruby-on-rails-4 actionmailer
Rectangle 27 48

I was using something along the lines of the currently accepted answer in order to send emails with an attached binary error log file. GMail and K-9 send it just fine and it also arrives fine on my mail server. The only problem was my mail client of choice Thunderbird which had troubles with opening / saving the attached log file. In fact it simply didn't save the file at all without complaining.

I took a look at one of these mail's source codes and noticed that the log file attachment had (understandably) the mime type message/rfc822. Of course that attachment is not an attached email. But Thunderbird cannot cope with that tiny error gracefully. So that was kind of a bummer.

After a bit of research and experimenting I came up with the following solution:

public Intent createEmailOnlyChooserIntent(Intent source,
        CharSequence chooserTitle) {
        Stack<Intent> intents = new Stack<Intent>();
        Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
                "info@domain.com", null));
        List<ResolveInfo> activities = getPackageManager()
                .queryIntentActivities(i, 0);

        for(ResolveInfo ri : activities) {
            Intent target = new Intent(source);
            target.setPackage(ri.activityInfo.packageName);
            intents.add(target);
        }

        if(!intents.isEmpty()) {
            Intent chooserIntent = Intent.createChooser(intents.remove(0),
                    chooserTitle);
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
                    intents.toArray(new Parcelable[intents.size()]));

            return chooserIntent;
        } else {
            return Intent.createChooser(source, chooserTitle);
        }
    }

It can be used as follows:

Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("*/*");
        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(crashLogFile));
        i.putExtra(Intent.EXTRA_EMAIL, new String[] {
            ANDROID_SUPPORT_EMAIL
        });
        i.putExtra(Intent.EXTRA_SUBJECT, "Crash report");
        i.putExtra(Intent.EXTRA_TEXT, "Some crash report details");

        startActivity(createEmailOnlyChooserIntent(i, "Send via email"));

As you can see, the createEmailOnlyChooserIntent method can be easily fed with the correct intent and the correct mime type.

It then goes through the list of available activities that respond to an ACTION_SENDTO mailto protocol intent (which are email apps only) and constructs a chooser based on that list of activities and the original ACTION_SEND intent with the correct mime type.

Another advantage is that Skype is not listed anymore (which happens to respond to the rfc822 mime type).

i just inserted you code snippet and it works fine. Before there have been listed apps like Google Drive, Skype etc. But isn't there a way to send a mail out of the application without calling another application? i just read the article about the email client that @Rene postet above but seems to be too complicated for just sending a simple email

Excellent answer. I had Skype and Google Drive coming up with ACTION_SEND as well and this sorts it out beautifully.

The most popular solution above returns Skype and Vkontakte as well. This solution is better.

what is crashLogFile ?where did it initialise?pease sepecify

@Noufal This is just some remainder from my own code base. It's a File instance pointing to a crash log file my Android apps create in the background in case there was an uncaught exception. That example should just illustrate how to add an email attachment. You could also attach any other file from the external storage (an image for example). You can also remove that line with crashLogFile in order to get a working example.

How can I send emails from my Android application? - Stack Overflow

android email
Rectangle 27 46

I was using something along the lines of the currently accepted answer in order to send emails with an attached binary error log file. GMail and K-9 send it just fine and it also arrives fine on my mail server. The only problem was my mail client of choice Thunderbird which had troubles with opening / saving the attached log file. In fact it simply didn't save the file at all without complaining.

I took a look at one of these mail's source codes and noticed that the log file attachment had (understandably) the mime type message/rfc822. Of course that attachment is not an attached email. But Thunderbird cannot cope with that tiny error gracefully. So that was kind of a bummer.

After a bit of research and experimenting I came up with the following solution:

public Intent createEmailOnlyChooserIntent(Intent source,
        CharSequence chooserTitle) {
        Stack<Intent> intents = new Stack<Intent>();
        Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
                "info@domain.com", null));
        List<ResolveInfo> activities = getPackageManager()
                .queryIntentActivities(i, 0);

        for(ResolveInfo ri : activities) {
            Intent target = new Intent(source);
            target.setPackage(ri.activityInfo.packageName);
            intents.add(target);
        }

        if(!intents.isEmpty()) {
            Intent chooserIntent = Intent.createChooser(intents.remove(0),
                    chooserTitle);
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
                    intents.toArray(new Parcelable[intents.size()]));

            return chooserIntent;
        } else {
            return Intent.createChooser(source, chooserTitle);
        }
    }

It can be used as follows:

Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("*/*");
        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(crashLogFile));
        i.putExtra(Intent.EXTRA_EMAIL, new String[] {
            ANDROID_SUPPORT_EMAIL
        });
        i.putExtra(Intent.EXTRA_SUBJECT, "Crash report");
        i.putExtra(Intent.EXTRA_TEXT, "Some crash report details");

        startActivity(createEmailOnlyChooserIntent(i, "Send via email"));

As you can see, the createEmailOnlyChooserIntent method can be easily fed with the correct intent and the correct mime type.

It then goes through the list of available activities that respond to an ACTION_SENDTO mailto protocol intent (which are email apps only) and constructs a chooser based on that list of activities and the original ACTION_SEND intent with the correct mime type.

Another advantage is that Skype is not listed anymore (which happens to respond to the rfc822 mime type).

i just inserted you code snippet and it works fine. Before there have been listed apps like Google Drive, Skype etc. But isn't there a way to send a mail out of the application without calling another application? i just read the article about the email client that @Rene postet above but seems to be too complicated for just sending a simple email

Excellent answer. I had Skype and Google Drive coming up with ACTION_SEND as well and this sorts it out beautifully.

The most popular solution above returns Skype and Vkontakte as well. This solution is better.

what is crashLogFile ?where did it initialise?pease sepecify

@Noufal This is just some remainder from my own code base. It's a File instance pointing to a crash log file my Android apps create in the background in case there was an uncaught exception. That example should just illustrate how to add an email attachment. You could also attach any other file from the external storage (an image for example). You can also remove that line with crashLogFile in order to get a working example.

How can I send emails from my Android application? - Stack Overflow

android email
Rectangle 27 1

I think what you are asking is outbound sender email which is similar to Mailgun. One such service is Amazon SES which is already incorporated into AWS Mobile SDK. It even has a nice tutorial to implement it in Android. Both SES and Mailgun require a verified sender so technically you will be sending emails from your own domain and have nothing to do with user's email.

email - send mail from android without using smtp and user interaction...

android email mailgun
Rectangle 27 1

I use sendmail for email in CI. Before using send mail you have to do some configurations in CI.

First, go to system/libraries/Email.php and change the following

class CI_Email {

  var   $useragent      = "CodeIgniter";
  var   $mailpath       = "/usr/sbin/sendmail"; // Sendmail path
  var   $protocol       = "sendmail";   // mail/sendmail/smtp
  var   $smtp_host      = "mail.blah-blah.com";     // SMTP Server.  


  .....
}
public function send_mail($email, $subject, $message){
        //$this->load->library( 'email' );
        $this->email->from( 'no-reply@blah-blah.com', 'blah-blah.com' );
        $this->email->to( $email);
        $this->email->subject( $subject );
        $this->email->message( $message );
        $this->email->send();

        echo $this->email->print_debugger();

    }

That's all. you can use the send_mail method to send emails now.

The line echo $this->email->print_debugger(); will never execute due to the return statement above it. Better to check the success of the send() call, and then conditionally return or print_debugger() based on that.

php - Cannot send email using CodeIgniter's email library - Stack Over...

php codeigniter email smtp gmail
Rectangle 27 1

I use sendmail for email in CI. Before using send mail you have to do some configurations in CI.

First, go to system/libraries/Email.php and change the following

class CI_Email {

  var   $useragent      = "CodeIgniter";
  var   $mailpath       = "/usr/sbin/sendmail"; // Sendmail path
  var   $protocol       = "sendmail";   // mail/sendmail/smtp
  var   $smtp_host      = "mail.blah-blah.com";     // SMTP Server.  


  .....
}
public function send_mail($email, $subject, $message){
        //$this->load->library( 'email' );
        $this->email->from( 'no-reply@blah-blah.com', 'blah-blah.com' );
        $this->email->to( $email);
        $this->email->subject( $subject );
        $this->email->message( $message );
        $this->email->send();

        echo $this->email->print_debugger();

    }

That's all. you can use the send_mail method to send emails now.

The line echo $this->email->print_debugger(); will never execute due to the return statement above it. Better to check the success of the send() call, and then conditionally return or print_debugger() based on that.

php - Cannot send email using CodeIgniter's email library - Stack Over...

php codeigniter email smtp gmail
Rectangle 27 272

mail.To and mail.From are readonly. Move them to the constructor.

using System.Net.Mail;

...

MailMessage mail = new MailMessage("you@yourcompany.com", "user@hotmail.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.google.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);

-1 your code will work, but they are not readonly

mail.To is readonly, from is not. public MailAddressCollection To { get; }

That's because it's a collection. You can just call add to it

@Oskar Okay, so I should have been more specific. You cannot set the mail.to to a specific address. You must use the constructor or call add. I was only addressing the first compiler warning: Error CS0200: Property or indexer 'System.Net.Mail.MailMessage.To' cannot be assigned to -- it is read only

@DougHauf You can use the SmtpClient class with a password protected smtp server. your smtp server seems to be an internal server which would mean that your program will only be able to connect to that smtp server when it's on the network. client.Host = "mail.youroutgoingsmtpserver.com"; client.Credentials = new System.Net.NetworkCredential("yourusername", "yourpassword");

email - Send e-mail via SMTP using C# - Stack Overflow

c# email smtpclient