| Author |  | 
      
        | grifonius Newbie
 
  
 
 Joined: 22 August 2019
 Online Status: Offline
 Posts: 3
 | 
          Hi.
           | Posted: 22 August 2019 at 4:03pm | IP Logged |   |  
           | 
 |  
 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: 2207
 | 
          Hi,
           | Posted: 23 August 2019 at 1:39am | IP Logged |   |  
           | 
 |  
 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
 | 
          Hi,
           | Posted: 23 August 2019 at 4:54am | IP Logged |   |  
           | 
 |  
 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: 2207
 | 
          You can build the message and then replace boundary manually by search-replace in the generated raw data.
           | Posted: 23 August 2019 at 5:07am | IP Logged |   |  
           | 
 |  
 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
 | 
          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:
           | Posted: 23 August 2019 at 8:54am | IP Logged |   |  
           | 
 |  
 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: 2207
 | 
          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.
           | Posted: 23 August 2019 at 9:07am | IP Logged |   |  
           | 
 |  
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  |