Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi friends,
 

How can able to send a mail with any kind of service providers. I don't want to restrict the Customer with only Gmail.
 

Kindly help me......
Posted 28-Mar-13 0:33am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

The Microsoft .NET framework provides two namespaces, System.Net and System.Net.Sockets to send or receive data over the Internet. SMTP protocol is using for sending email from C#. C# use System.Net.Mail namespace for sending email.To send e-mail you need to configure SMTP server. If you don’t have any SMTP, you can use free SMTP server. You can also use your gmail account.
 
More details with example: http://cybarlab.blogspot.com/2013/03/send-e-mail-using-c-sharp.html
 
Hope it will help you.
 
Tanks & best regard
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Simply use config file: http://hazaa.com.au/blog/how-to-store-smtp-mail-settings-in-the-appconfig-or-webconfig-file/[^], or provide your own configuration mechanism and set the necessary SmtpClient properties by code.
A useful article in this topic: Sending Mails in .NET Framework[^]
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
use this one might be helps you.
 

protected void SendEMail(string MailTo, string MailFrom, string MailSubject, string MailBody,string CC, string BCC,string Host,string Password,int PortNo)
{
MailMessage objEmail = new MailMessage();

objEmail.From = new MailAddress(MailFrom);

string[] MailItem = MailTo.Split(';');
for (int i = 0; i < MailItem.Length; i++)
{
objEmail.To.Add(new MailAddress(MailItem[i]));
}
 
objEmail.Subject = MailSubject;
objEmail.Body = MailBody;
objEmail.IsBodyHtml = true;
objEmail.Sender = new MailAddress(MailFrom);
objEmail.Priority = MailPriority.High;

try
{
SmtpClient client = new SmtpClient();
client.Host = Host;
ICredentialsByHost crd = new NetworkCredential(MailFrom, Password);
client.Credentials = crd;
client.EnableSsl = true;
client.Port = PortNo;
client.Send(objEmail);
}
catch (Exception exc)
{
}
}
 
Calling Pattern :
 
SendEMail("ToEMAIL", "FromMAIL", "Subject Line", "Mail Content", "CC ID", "BCC ID","smtp.gmail.com", "Password",587);
  Permalink  
Comments
Member 9501115 at 28-Mar-13 5:56am
   
smtp.gmail.com is used only with gmail.....if i m the yahoo user then?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100