A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.69.240.69:25
Dim smtpClient As New SmtpClient()
Dim message As New MailMessage()
Dim fromAddress As New MailAddress("news#ffff.ca")
smtpClient.Host = "smtp10.bellnet.ca"
smtpClient.Credentials = New NetworkCredential("news", "1235!")
smtpClient.Port = "25"
message.From = fromAddress
message.To.Add("khs#ddddd.com")
message.Subject = "eyjeyjey afsdf"
message.Body = "Hello from aaaaa"
message.IsBodyHtml = True
smtpClient.EnableSsl = True
smtpClient.Send(message)
Bell Canada blocks the default SMTP port of 25.
See this link for a partial list.
Related
this was my code for my local machine before my company switched to outlook 365:
SmtpClient SMTP Client = new SmtpClient(ConfigurationManager.AppSettings["EMailServer"]);
smtpClient.Send(message);
Since the outlook was changed, I google and find this code, however it does not work giving error code "Failed to send email" "General failure".
Please help me to resolve this issue
here is a new code:
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredentmailial("email address", "network password");
client.Port = 25; // You can use Port 25 if 587 is blocked (mine is!)
client.Host = "smtp.office365.com";
//client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.TargetName = "STARTTLS/smtp.office365.com";
client.Send(message);
Thank you very much.
Vitaly.
This is the code I use to send the email using HOST smtp.office365.com
var fromAddress = new MailAddress("from#domain.com", "From Name");
var toAddress = new MailAddress("to#domain.com", "To Name");
string fromPassword = "Your_email_password";
string subject = "Test Subject";
string body = "Test Message";
var smtp = new SmtpClient
{
Host = "smtp.office365.com",
Port = 25, //Recommended port is 587
EnableSsl = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body,
IsBodyHtml = true
})
{
smtp.Send(message);
}
Please check that is your port 25 is blocked by OS or not.
I am using below code to send email to webmail GoDaddy and it is working fine from my local machine and when deployed on client server it is not working.
Below is my code :
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
MailAddress fromAddress = new MailAddress("xyz#com");
message.From = fromAddress;
message.To.Add("abc#gmail.com");
message.Subject = "test Message";
message.IsBodyHtml = true;
message.Body = "we are here";
smtpClient.Host = "mail.trustwellhospitals.com";
smtpClient.Port = 25;
smtpClient.EnableSsl = false;
smtpClient.UseDefaultCredentials = false;
System.Net.NetworkCredential("username", "password");
smtpClient.Send(message);
i'm having a problem with sending mail. my code is so easy as below.
when this code starts it gives the error:
Request for the permission of type 'System.Net.Mail.SmtpPermission,
System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
when i searched for this error, they recommend changing web.config trust full setting or port from 587 to 25 and other stuff, but none work. what else could it be?
Sub MailGonder()
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Host = "mail.excelinefendisi.com"
SmtpServer.Credentials = New Net.NetworkCredential("info#excelinefendisi.com", "mypassword")
SmtpServer.Port = 587
mail.From = New MailAddress("info#excelinefendisi.com")
mail.To.Add("volkan.yurtseven#hotmail.com")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP"
SmtpServer.EnableSsl = True
SmtpServer.Send(mail)
End Sub
Use this code, work perfect for me :
Dim iphost As IPHostEntry = Dns.GetHostByName(Dns.GetHostName())
Dim Emailmessage As New MailMessage()
Emailmessage.From = New MailAddress("from_Email#hotmail.com")
Emailmessage.To.Add("To_Email#hotmail.com")
Emailmessage.Subject = "tTest Mail"
Emailmessage.Body = ("This is for testing SMTP")
Dim smtp As New SmtpClient("smtp.live.com")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("your_email#hotmail.com.com", "Password")
smtp.Send(Emailmessage)
Sometimes following code sends Email,Sometimes i get SMTP Exception saying "failure in sending Email".Why is this happening? following is the code i have written.Plesae tell me why sometime i get email sent and sometime why i get Exception.
StringBuilder mailBody = new StringBuilder();
mailBody.Append("Hi <br/>")
MailMessage message = new MailMessage("from#gmail.com", "to#gmail.com");
message.Subject = "Subject";
message.Body = mailBody.ToString();
SmtpClient smtpclient = new SmtpClient("smtp.gmail.com", 587);
smtpclient.Credentials = new System.Net.NetworkCredential()
{ UserName = "from#gmail.com",
Password = "password"
};
smtpclient.EnableSsl = true;
message.IsBodyHtml = true;
smtpclient.Send(message);
I want to attach a file dynamically and send it through mail. So can someone please let me know how can i send it with attachment.
You can use this code.
using System.Net.Mail;
private void SendEmail()
{
MailMessage message = new MailMessage();
message.From = new MailAddress("YourEmailAddress#domain.com");
message.To.Add(new MailAddress("Recipient#domain.com"));
message.Subject = "Subject";
message.Body = "Email Message Body";
// Add attachment
string attachmentPath = Server.MapPath("~/AttachmentPath.jpg");
message.Attachments.Add(new Attachment(attachmentPath));
// Connect to GoDaddy SMTP
SmtpClient smtp = new SmtpClient("relay-hosting.secureserver.net");
smtp.Credentials = new System.Net.NetworkCredential("Username","Password");
smtp.Port = 25;
smtp.EnableSsl = false;
// Send the message
smtp.Send(message);
}
you can try with this code
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("...");/:Adjust your adress
mail.From = new MailAddress("your_email_address#gmail.com");
mail.To.Add("to_address");
mail.Subject = "Test Mail";
mail.Body = "mail with attachment";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("your attachment file");
mail.Attachments.Add(attachment);
SmtpServer.Port = ..; //Replace with your port number
SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);