Comments on: Send HTML email https://www.limilabs.com/blog/send-html-email Using Limilabs .net components Tue, 18 Jul 2017 11:37:48 +0000 hourly 1 https://wordpress.org/?v=6.6.2 By: Limilabs support https://www.limilabs.com/blog/send-html-email#comment-574812 Fri, 11 Oct 2013 06:45:41 +0000 http://www.limilabs.com/blog/?p=1284#comment-574812 In reply to Aneesh Kumar.

@Aneesh

It is Gmail that takes that much time, please contact their support, if you believe it should act faster.

“No identity changes permitted. im2sm50492321pbd.31 – gsmtp” error

This error is generated by the server.

You can login to the server only once. Which means that you need a separate connection for every user you try to login as. Please note that this is not Mail.dll’s limitation nor bug – this is how SMTP protocol, and in fact all mail protocols, work.

Only advice I have for you is to create multiple threads, each with its own Smtp class instance, and send several emails through Gmail simultaneously.

]]>
By: Aneesh Kumar https://www.limilabs.com/blog/send-html-email#comment-574604 Thu, 10 Oct 2013 05:29:07 +0000 http://www.limilabs.com/blog/?p=1284#comment-574604 The subsequent calls takes 2 seconds to sent mail which is fine.
But for our case every time the access token changes. So whenever we sent a message we need to do this LoginOAUTH2 as below. But this gives an exception saying “No identity changes permitted. im2sm50492321pbd.31 – gsmtp”

using(Smtp smtp = new Smtp())
{
    smtp.ConnectSSL("smtp.gmail.com");
    for (int i = 0; i < 5; i++)
    {
        smtp.LoginOAUTH2(from, accesstoken);  // this gives an exception 
        SendMessageResult result = smtp.SendMessage(email);
    }
    smtp.Close()
}

Regards,
Aneesh Kumar.

]]>
By: Limilabs support https://www.limilabs.com/blog/send-html-email#comment-574502 Wed, 09 Oct 2013 07:27:51 +0000 http://www.limilabs.com/blog/?p=1284#comment-574502 In reply to Aneesh Kumar.

@Aneesh,

Which part takes so long? OAuth2? Are you reusing Smtp object?
Could it be that this is a problem with your network? Gmail server? Gmail is known for enforcing many limits on its users.

I don’t believe that this is the problem with Mail.dll – its speed is up to 230 ms/100 emails (local server). Generally on production servers its much less than 200ms/email (around 20-50ms)

The only “problem” I can see in your code is, that you can use ConnectSSL instead of Connect and StartTLS sequence:

smtp.ConnectSSL("smtp.gmail.com");
]]>
By: Aneesh Kumar https://www.limilabs.com/blog/send-html-email#comment-574458 Wed, 09 Oct 2013 00:40:37 +0000 http://www.limilabs.com/blog/?p=1284#comment-574458 We were trying to send email using the Limilabs Mail.dll.
Below is the snippet we are using to send an E-mail

using (Smtp smtp = new Smtp())
{
    smtp.Connect("smtp.gmail.com", 587);                 
    smtp.StartTLS();
    smtp.LoginOAUTH2(from, accessToken);
    SendMessageResult result = smtp.SendMessage(email);
    smtp.Close();
}

It takes 6 to 7 second to send E-mail which is a worry. Could you let us know what could be the reason. If we purchase will this speed be better.

Regards,
Aneesh Kumar

]]>
By: Limilabs support https://www.limilabs.com/blog/send-html-email#comment-573930 Fri, 04 Oct 2013 08:20:09 +0000 http://www.limilabs.com/blog/?p=1284#comment-573930 In reply to Aneesh Kumar.

@Aneesh,

1. MailBuilder class is not indented to be serialized, or transferred between client and server.
2. Classes, such as ContentType, MimeType can not have default constructor, so XML serialization won’t work for them.
3. There are properties with type of interface (such as IList) on MailBuilder, which will also prevent serialization.
4. It is not possible (not secure) to transfer certificate classes, used for signing or encrypting emails, between two machines.

The bottom line is: use MailBuilder to create or parse emails, but don’t use it as a data transfer object (DTO) – it was not designed for this purpose.

]]>
By: Aneesh Kumar https://www.limilabs.com/blog/send-html-email#comment-573890 Fri, 04 Oct 2013 02:16:49 +0000 http://www.limilabs.com/blog/?p=1284#comment-573890 I need to sent the MailBuilder dataobject filled form Client and sent to server through WebServices. But I am getting the error saying “There was an error reflecting property ‘MailBuilder'”.
There was an error reflecting type ‘Limilabs.Mail.MailBuilder’.
Limilabs.Mail.Headers.ContentType cannot be serialized because it does not have a parameterless constructor.

Any help is appreciated

]]>
By: lana https://www.limilabs.com/blog/send-html-email#comment-1508 Mon, 16 May 2011 13:18:34 +0000 http://www.limilabs.com/blog/?p=1284#comment-1508 Thanks again.
Using AddAlternative method with Rtf property just garbled the message, but I found a neat conversion function at http://www.codeproject.com/KB/string/EasyRTF_To_HTML_.aspx
so I reverted back to Html property:

builder.Html = sRTF_To_HTML(RichTextBox1.Rtf);

and it worked like a charm! Thanks again.

]]>
By: Limilabs support https://www.limilabs.com/blog/send-html-email#comment-1507 Mon, 16 May 2011 06:45:33 +0000 http://www.limilabs.com/blog/?p=1284#comment-1507 In reply to lana.

@lana

1.
[from msdn]
The Text property does not return any information about the formatting applied to the contents of the RichTextBox.
To get the rich text formatting (RTF) codes, use the Rtf property.

2.
Are you sure that your email client supports rtf content?
What email client are you using?

]]>
By: lana https://www.limilabs.com/blog/send-html-email#comment-1506 Mon, 16 May 2011 03:21:46 +0000 http://www.limilabs.com/blog/?p=1284#comment-1506 Thanks,
I am sorry, I should have been more specific: I am using vb.net (very new at it). I’ve tried to translate it:

Dim rtf = New MimeFactory().CreateMimeText()
rtf.ContentType = New ContentType(MimeType.Text, MimeSubtype.Rtf)
rtf.Text = RichTextBox1.Text
builder.AddAlternative(rtf)

Dim email As IMail = builder.Create()

but it did not work for me, it just attached a plane text file ‘noname’ to the email. I must be doing it wrong…

]]>
By: Limilabs support https://www.limilabs.com/blog/send-html-email#comment-1505 Sun, 15 May 2011 18:36:28 +0000 http://www.limilabs.com/blog/?p=1284#comment-1505 In reply to lana.

@Lana

You can use AddAlternative method:

MailBuilder builder = new MailBuilder();
builder.Text = "plain text";
var rtf = new MimeFactory().CreateMimeText();
rtf.ContentType = new ContentType(MimeType.Text, MimeSubtype.Rtf);
rtf.Text = @"{rtf1ansideff0
{colortbl;red0green0blue0;red255green0blue0;}
This line is the default colorline
cf2
This line is redline
cf1
This line is the default color
}";
builder.AddAlternative(rtf);
IMail mail = builder.Create();

Please note that not all email clients support and are able to display RTF formatted email.

]]>