Author |
|
grifonius Newbie
Joined: 22 August 2019
Online Status: Offline Posts: 3
|
Posted: 22 August 2019 at 4:03pm | IP Logged
|
|
|
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 |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 23 August 2019 at 1:39am | IP Logged
|
|
|
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 |
|
|
grifonius Newbie
Joined: 22 August 2019
Online Status: Offline Posts: 3
|
Posted: 23 August 2019 at 4:54am | IP Logged
|
|
|
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 |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 23 August 2019 at 5:07am | IP Logged
|
|
|
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 |
|
|
grifonius Newbie
Joined: 22 August 2019
Online Status: Offline Posts: 3
|
Posted: 23 August 2019 at 8:54am | IP Logged
|
|
|
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 |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 23 August 2019 at 9:07am | IP Logged
|
|
|
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 |
|
|