Just use Attachment class constructor and then set the TransferEncoding to base64 as in the example below:
var message = new MailMessage
{
From = "from",
To = "to",
Subject = "subject",
BodyText = "email body"
};
Attachment attachment = new Attachment(@"C:\MyData\file.txt", "file.txt");
attachment.TransferEncoding = TransferEncoding.Base64;
message.Attachments.Add(attachment);
// save the message
message.Save(@"C:\MyData\mail-with-base64-attachment.eml");
// or send the message
Smtp smtp = new Smtp();
smtp.Connect("server");
smtp.Login("username", "password");
smtp.Send(message);
The component will handle the base64 conversion automatically. Apart from Base64 Transfer Encoding, you can use QuotedPrintable, Binary, SevenBit and EightBit Transfer Encoding.