using(MemoryStream imageStream = new MemoryStream())
{
//create a bitmap image
Bitmap b = graphBuilder.BuildImageGraph(...);
b.Save(imageStream,System.Drawing.Imaging.ImageFormat.Jpeg);
EmailMessage emailMessage = new EmailMessage();
//email details
//...
FileAttachment relatedFileAttachment = new FileAttachment(imageStream.GetBuffer(), "a1");
emailMessage.AddRelatedAttachment( relatedFileAttachment );
SmtpServer s = new SmtpServer("localhost");
}
When I verify my e-mail , i get only a part of the image.
Can you tell me why I get this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello...After I`ve read some of the threads , I found that my problem was solved by 'jatubio' in his thread : Corrupts Attachement!!!
...
int charstoread=Base64Encoder.MAX_CHARS_PER_LINE * 100;
This is a problem because the base64 conversion works on groups of 3 bytes (7600 / 3 isn't an integer number!), so you get a different results than converting the whole array!
A solution could be to convert the whole array all at once or to use a block size divisible by 3 (e.g. 76 * 102)
...
I`ve downloaded the sources and changed 100 with 102 and now it`s waorking!
See ya!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello...
Let`s say that we have the following C# code :
using(MemoryStream imageStream = new MemoryStream())
{
//create a bitmap image
Bitmap b = graphBuilder.BuildImageGraph(...);
b.Save(imageStream,System.Drawing.Imaging.ImageFormat.Jpeg);
EmailMessage emailMessage = new EmailMessage();
//email details
//...
FileAttachment relatedFileAttachment = new FileAttachment(imageStream.GetBuffer(), "a1");
emailMessage.AddRelatedAttachment( relatedFileAttachment );
SmtpServer s = new SmtpServer("localhost");
}
When I verify my e-mail , i get only a part of the image.
Can you tell me why I get this?
Hello...After I`ve read some of the threads , I found that my problem was solved by 'jatubio' in his thread : Corrupts Attachement!!!
...
int charstoread=Base64Encoder.MAX_CHARS_PER_LINE * 100;
This is a problem because the base64 conversion works on groups of 3 bytes (7600 / 3 isn't an integer number!), so you get a different results than converting the whole array!
A solution could be to convert the whole array all at once or to use a block size divisible by 3 (e.g. 76 * 102)
...
I`ve downloaded the sources and changed 100 with 102 and now it`s waorking!
See ya!