Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: Change Content-Type boundary string Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
grifonius
Newbie
Newbie


Joined: 22 August 2019
Online Status: Offline
Posts: 3
Posted: 22 August 2019 at 4:03pm | IP Logged Quote grifonius

Hi.

I'm new to MailBee.Net Objects and I'm trying to manually set the boundary string. How can I do that?

The message should look something like:

Content-Type: multipart/alternative; boundary="..."

--...
Content-Type: text/plain; charset="utf-8"

Some plain text.

--...
Content-Type: text/html; charset="utf-8"

Some HTML.

--...--


Any help appreciated.
Back to Top View grifonius's Profile Search for other posts by grifonius
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 23 August 2019 at 1:39am | IP Logged Quote Alex

Hi,

MailBee creates boundaries and MIME parts automatically. To create a structure like in your post, you simply need to set MailMessage.BodyPlainText and MailMessage.BodyHtmlText properties.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
grifonius
Newbie
Newbie


Joined: 22 August 2019
Online Status: Offline
Posts: 3
Posted: 23 August 2019 at 4:54am | IP Logged Quote grifonius

Hi,

Thank you. I know how to get the structure with MailMessage.BodyPlainText and MailMessage.BodyHtmlText, but I need to be able to set the boundary string somehow.

Regards,
Grifonius
Back to Top View grifonius's Profile Search for other posts by grifonius
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 23 August 2019 at 5:07am | IP Logged Quote Alex

You can build the message and then replace boundary manually by search-replace in the generated raw data.

Once the message is built, msg.MimePartTree.Boundary (msg is MailMessage) can be used to find out which boundary is in the message.

However, direct editing of the message data is not supported scenario. You can do this at your own risk. And it will break S/MIME and DKIM signatures and so on.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
grifonius
Newbie
Newbie


Joined: 22 August 2019
Online Status: Offline
Posts: 3
Posted: 23 August 2019 at 8:54am | IP Logged Quote grifonius

I am sorry, but I can't figure out how to change my code to do this. At the moment it looks something like this:

var message = new MailMessage
{
    From = { Email = senderAddress, DisplayName = senderName }
};

message.To.Add(receiverAddress, receiverName);
message.Subject = subject;
message.BodyHtmlText = text;

var mailer new Smtp();
mailer.SmtpServerAdd(serverAddress, userName, password).Port = port;
mailer.Message = message;

mailer.Send();


When I try to get message.MimePartTree.Boundary just before mailer.Send(); it is empty.
Back to Top View grifonius's Profile Search for other posts by grifonius
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 23 August 2019 at 9:07am | IP Logged Quote Alex

Because you didn't built the message yet. In your case, it gets built by Send method. You can build it manually by calling, let's say, MailMessage.GetMessageRawData method (which will also give you message's raw bytes which you'll then need to edit). Once you edited the message and produced the new raw bytes, you can load them back with MailMessage.LoadMessage(byte[]) method.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

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