I am created in my web application a send mail page that enable the user from sending email from the application without need to put his\her password.
the problem is when I run it it give me this exception :
550 5.7.1 Service unavailable, Client host [212.34.23.233] blocked using Spamhaus. To request removal from this list see http:
when the first time I used it , it sent the mail but I received it in the Spam e-mails .
how I can use the same way to send e-mails using this code or how I can edit it to make it in high performance .
What I have tried:
public void send_email()
{
SmtpMail oMail = new SmtpMail("TryIt");
SmtpClient oSmtp = new SmtpClient();
oMail.From = from.Text;
oMail.To = toddl.SelectedValue.ToString();
oMail.Subject = subject_txt.Text;
oMail.TextBody = txtBody.Text;
if(!string.IsNullOrWhiteSpace(ccddl1.SelectedValue.ToString()))
{
oMail.Cc.Add(new MailAddress(ccddl1.SelectedValue.ToString()));
}
if (!string.IsNullOrWhiteSpace(ccddl2.SelectedValue.ToString()))
{
oMail.Cc.Add(new MailAddress(ccddl2.SelectedValue.ToString()));
}
if (syllabus_attach.HasFile)
{
MemoryStream ms = new MemoryStream();
syllabus_attach.PostedFile.InputStream.CopyTo(ms);
var byts = ms.ToArray();
ms.Dispose();
string FileName = Path.GetFileName(syllabus_attach.PostedFile.FileName);
oMail.AddAttachment( FileName,byts);
}
if (course_exam_attach.HasFile)
{
MemoryStream ms = new MemoryStream();
course_exam_attach.PostedFile.InputStream.CopyTo(ms);
var byts = ms.ToArray();
ms.Dispose();
string FileName = Path.GetFileName(course_exam_attach.PostedFile.FileName);
oMail.AddAttachment(FileName, byts);
}
if (answer_key_attach.HasFile)
{
MemoryStream ms = new MemoryStream();
answer_key_attach.PostedFile.InputStream.CopyTo(ms);
var byts = ms.ToArray();
ms.Dispose();
string FileName = Path.GetFileName(answer_key_attach.PostedFile.FileName);
oMail.AddAttachment(FileName, byts);
}
if (Exam_Mode_form.HasFile)
{
MemoryStream ms = new MemoryStream();
Exam_Mode_form.PostedFile.InputStream.CopyTo(ms);
var byts = ms.ToArray();
ms.Dispose();
string FileName = Path.GetFileName(Exam_Mode_form.PostedFile.FileName);
oMail.AddAttachment(FileName, byts);
}
SmtpServer oServer = new SmtpServer("");
oSmtp.SendMail(oServer, oMail);
string script = "alert(\"Request Sent Successfully!!\");";
ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
}
}