miranda59
  • miranda59
  • 50.25% (Neutral)
  • Newbie Topic Starter
11 years ago
PLss help. this is the error i get when i try to send mail with image attachment using the html.csharp sample code:
Exception: NEtworking Error:10060 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 74.125.136.109.25
ivan
  • ivan
  • 100% (Exalted)
  • Administration
11 years ago

It seems that your outgoing 25 port is blocked by your router/firewall/anti-virus/ISP, in this case, you can try to use 587 or 465 port
in the sample, you can input

smtp.gmail.com 587
smtp.gmail.com 465

as the server address and have SSL checked, then try to send the email
miranda59
  • miranda59
  • 50.25% (Neutral)
  • Newbie Topic Starter
11 years ago
HI Ivan, Supper. Thanks! that worked.
How do i attach an html file to the body of the email not as an attachment.
Thanx
ivan
  • ivan
  • 100% (Exalted)
  • Administration
miranda59
  • miranda59
  • 50.25% (Neutral)
  • Newbie Topic Starter
11 years ago
Thanx Ivan, that worked only for a while then it starts sending only characters as the HTML.
I have tried creating a new html file which works only once or twice and then it starts sending the
chars again. Any suggestions?
ivan
  • ivan
  • 100% (Exalted)
  • Administration
11 years ago
could you show me your source code?
miranda59
  • miranda59
  • 50.25% (Neutral)
  • Newbie Topic Starter
11 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// Add EASendMail namespace
using EASendMail;

namespace EmailList
{
class Program
{
static void Main(string[] args)
{


SmtpMail oMail = new SmtpMail("TryIt");
SmtpClient oSmtp = new SmtpClient();

// Set sender email address, please change it to yours
oMail.From = "from email";

// Set recipient email address, please change it to yours
oMail.To = "to email";

// Set email subject
oMail.Subject = "Cocktail Invite";


// Your SMTP server address
SmtpServer oServer = new SmtpServer("smtp.gmail.com");

// User and password for ESMTP authentication, if your server doesn't require
// User authentication, please remove the following codes.
oServer.User = "mymail";
oServer.Password = "mypass";

// If your smtp server requires implicit SSL connection on 465 port, please add this line
oServer.Port = 465;
oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;


try
{
// Import html body and also import linked image as embedded images.
oMail.ImportHtmlBody("C:\\Users\\COMPUTER2\\Desktop\\test.htm",
ImportHtmlBodyOptions.ImportLocalPictures | ImportHtmlBodyOptions.ImportCss);

oMail.SaveAs("C:\\Users\\COMPUTER2\\Desktop\\test.htm", true);

Console.WriteLine("start to send email ...");
oSmtp.SendMail(oServer, oMail);
Console.WriteLine("email was sent successfully!");
}
catch (Exception ep)
{
Console.WriteLine("failed to send email with the following error:");
Console.WriteLine(ep.Message);
}
}
}
}


ivan
  • ivan
  • 100% (Exalted)
  • Administration
11 years ago
Your codes have no problem.

when you

call

oMail.SaveAs("C:\\Users\\COMPUTER2\\Desktop\\test.htm", true);

please save it as

oMail.SaveAs("C:\\Users\\COMPUTER2\\Desktop\\test.eml", true);

then you can see the correct email.
miranda59
  • miranda59
  • 50.25% (Neutral)
  • Newbie Topic Starter
11 years ago
Thnx Ivan. that solved it

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.