This project is read-only.

How to use attachments / insert html content

Mar 11, 2012 at 4:38 PM

Hello All,

             I am new to HigLabo and have a couple of beginners' type questions.  I am intending to use HigLabo from an ASP.NET website. I have chosen HigLabo because it allows me to connect to gmail, specifying SSL as the security mechanism. I could not get System.NET.Mail to connect using SSL. Am I correct in assuming that to send attachments with an email, I should add to the Contents field of the SmtpMessage :

            SmtpMessage msg = new SmtpMessage();

            SmtpContent content = new SmtpContent();

            content.LoadData(// Some param //);

            msg.Contents.Add (content);


If so, the great. If I imagine "Contents" = "Attachments" that seems OK. Not sure with this mechanism, how I preserve the filename of the Content / Attachment.

The other problem is how to specify that the BodyText is in HTML format ? There does not seem to be a straight forward way to specify this. I have tried sending a mail where the BodyText is in HTML but the receiving email client renders it in text, not HTML. (In the System.Net.Mail which comes as standard with .NET, there is a simple property called IsHtml which I can set. When I set this property, the receiving client renders the incoming mail as HTML).

Any observations / answers here would be much appreciated.

Mar 12, 2012 at 1:53 AM

You can set filename by setting FileName or Name property of SmtpContent object.

And thank you for your suggestion about HTML format mail.
I'll create some intuitive API to send HTML format mail.
Please wait.

Mar 12, 2012 at 4:45 AM

I uploaded new version that include HTML format mail functionality.
You can send HTML format mail like below.
//Send mail
SmtpClient cl = new SmtpClient();
cl.ServerName = "your server name";
cl.Port = 25;
cl.Ssl = false;
SmtpMessage mg = new SmtpMessage();
mg.Subject = "title";
mg.BodyText = " mail body text!";
//Send by HTML format
mg.IsHtml = true; <--Set IsHtml is true
mg.From = "";
mg.To.Add(new MailAddress(""));
var rs = cl.SendMail(mg);
//Check mail was sent or not
if (rs.SendSuccessfull == false)

    //You can get information about send mail is success or error reason
    var resultState = rs.State;



Check it out!!

Mar 12, 2012 at 12:14 PM

I have downloaded and used the new IsHtml property. It works just fine when my BodyText includes some standard HTML tags.


Thank you for your prompt reply on this matter - it is much appreciated.  If you ever need any help with maintaining the source, please just ask.

Mar 12, 2012 at 3:42 PM

Oh yes.
I'm glad to help you!

I want to help more people who work with mail or other webservice etc...
I just need help to inform other developer about HigLabo library.
If you have your blog or account for some developer forum(like stackoverflow), I want you to post about HigLabo.
I posted stackoverflow last year, but sadly moderator delete all of my posts as spam.
Here is a list

Thank you for your support.