TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kishan Vaghasiya
NA
7
3.5k
unable to connect to the remote server c# smtp gmail
Aug 19 2017 3:41 AM
public string SendMail(string Emailids, string subject, string body)
{
string eroorMessage = string.Empty;
try
{
string hostname = ConfigurationManager.AppSettings["contactHost"];
int portno = Convert.ToInt32(ConfigurationManager.AppSettings["contactPort"]);
string frommailid = ConfigurationManager.AppSettings["contactMail"];
string frompwd = ConfigurationManager.AppSettings["contactPassword"];
var sendlist = Emailids.Split(',');
var Tolen = sendlist.Length;
string to = "";
if (Tolen == 1)
{
to = Emailids.Trim(',');
}
else
{
for (int i = 0; i < Tolen; i++)
{
to = sendlist[i];
}
}
var smptClient = new SmtpClient(hostname, portno)
{
Credentials = new NetworkCredential(frommailid, frompwd),
EnableSsl = true
};
smptClient.Send(frommailid, to, subject, body);
return "scucess";
}
catch (Exception ex)
{
eroorMessage = ex.Message.ToString() + ex.StackTrace.ToString() + ex.InnerException.ToString();
return eroorMessage;
}
}
Reply
Answers (
2
)
Old DLL fails in VS 2012.
Calling interface driven method from one project to another