Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: different content in plaintext and html Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Aishi
Newbie
Newbie
Avatar

Joined: 15 June 2015
Location: Russian Federation
Online Status: Offline
Posts: 3
Posted: 15 June 2015 at 4:29am | IP Logged Quote Aishi

Hello.

I use old version of MailBee.Net (7.1.2.340).
I send messages with MailBee.SmtpMail.Smtp.

sample of code:
Code:

var mailer = new MailBee.SmtpMail.Smtp();
var smtpserver = new MailBee.SmtpMail.SmtpServer(smtp.Server);
//auth settings for smtpserver .....
mailer.SmtpServers.Add(smtpserver);
mailer.Connect();
mailer.Hello();

if (authorizationmode != (int)SmtpAuthorizationMode.None)
   mailer.Login();

foreach(var notification in notifications)
{
   mailer.ResetMessage();

   mailer.Subject = notification.Subject.GetFirstSubstring(99);
   mailer.BodyHtmlText = notification.Body;
   mailer.Message.Charset = "utf-8";
   mailer.Message.EncodeAllHeaders(System.Text.Encoding.UTF8, HeaderEncodingOptions.None);
   mailer.From.AsString = notification.EmailFrom;
   mailer.To.Add(notification.EmailTo);
   mailer.Message.From = new EmailAddress(notification.EmailFrom);
   mailer.Message.To = new EmailAddressCollection(notification.EmailTo);
   mailer.Send();   
}


I have a problem with some messages. Some messages look is good, but some messages contains 2 different parts of mail: html part is real for mail's subject but plaintext part is from another notification in my list of notification.

Question: maybe my code is wrong?
Or maybe it is a bug in MailBee.Net v.7.1.2?
If it is bug then new version help me resolve this problem?
Back to Top View Aishi's Profile Search for other posts by Aishi
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 15 June 2015 at 5:28am | IP Logged Quote Igor

In your code, you're setting BodyHtmlText property but BodyPlainText isn't explicitly set anywhere. You should either call MakePlainBodyFromHtmlBody method after assigning HTML body, or make sure MessageBuilderConfig.HtmlToPlainMode is set to HtmlToPlainAutoConvert.IfHtml value.

Also, you seem to be setting From and To twice, through mailer and mailer.Message, setting via either of those should suffice.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
Aishi
Newbie
Newbie
Avatar

Joined: 15 June 2015
Location: Russian Federation
Online Status: Offline
Posts: 3
Posted: 16 June 2015 at 12:05am | IP Logged Quote Aishi

Thanks for your reply.

I try this

Code:

mailer.Message.Subject = notification.Subject.GetFirstSubstring(99);
mailer.Message.BodyHtmlText = notification.Body;
mailer.Message.MakePlainBodyFromHtmlBody();
mailer.Message.Charset = "utf-8";
mailer.Message.EncodeAllHeaders(System.Text.Encoding.UTF8, HeaderEncodingOptions.None);
mailer.Message.From = new EmailAddress(eMailFrom);
mailer.Message.To = new EmailAddressCollection(email);


If this doesn't help, then I will write a new message here
Back to Top View Aishi's Profile Search for other posts by Aishi
 
Aishi
Newbie
Newbie
Avatar

Joined: 15 June 2015
Location: Russian Federation
Online Status: Offline
Posts: 3
Posted: 01 July 2015 at 1:03am | IP Logged Quote Aishi

This decision helped me.

Thanks!!
Back to Top View Aishi's Profile Search for other posts by Aishi
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide