I am getting the exception as
Mailbox name not allowed. The server response was: Sorry, your
envelope sender is in my badmailfrom list.
Here is the code to send the email
public void SendEmail()
{
try
{
string Smtp_Client = System.Configuration.ConfigurationManager.AppSettings["Smtp_Client"];
string NewtwrkCredentials_Uname = System.Configuration.ConfigurationManager.AppSettings["NewtwrkCredentials_Uname"];
string NewtwrkCredentials_P = System.Configuration.ConfigurationManager.AppSettings["NewtwrkCredentials_P"];
//Declaration a list of attendees
MailAddressCollection macCollection = new MailAddressCollection();
//Add attendde. In this example, I send invite to only one
macCollection.Add(new MailAddress("****@****.com"));
//Create mail message
MailMessage mmMessage = formMailMessage("Test", "Test", "***.***@gmail.com", macCollection);
//Create smtp client
SmtpClient smtp = new SmtpClient("smtpout.europe.secureserver.net", 25);
//Configure your smtp client
smtp.EnableSsl = false;
smtp.Credentials = new NetworkCredential("****@*****.com", "****");
//Send it
smtp.Send(mmMessage);
}
catch (Exception er)
{
}
}
public static MailMessage formMailMessage(string strSubject, string strBodyHTML, string Email, MailAddressCollection macAttendeeList)
{
//Create an instance of mail message
MailMessage mmMessage = new MailMessage();
// Set up the different mime types contained in the message
System.Net.Mime.ContentType typeText = new System.Net.Mime.ContentType("text/plain");
System.Net.Mime.ContentType typeHTML = new System.Net.Mime.ContentType("text/html");
AlternateView viewHTML = AlternateView.CreateAlternateViewFromString(strBodyHTML, typeHTML);
mmMessage.AlternateViews.Add(viewHTML);
//Adress the message
mmMessage.From = new MailAddress(Email);
foreach (MailAddress attendee in macAttendeeList)
{
mmMessage.To.Add(attendee);
}
mmMessage.Subject = strSubject;
return mmMessage;
}
Can anyone help me with the code as to what am i doing wrong? i created a console application and used the same piece of code and it worked fine. the smtp server, network credentials are all proper.
Kindly Help
No idea what the issue was i used a different smtp server and the code worked.