I'm getting a System.OutOfMemoryException when I do a Login command on my smtp client. Why would this happen?

asked 03 Mar '10, 19:11

Lisa%20Robinson's gravatar image

Lisa Robinson
16
accept rate: 0%

edited 10 Aug '10, 13:33

Rebex%20KB's gravatar image

Rebex KB ♦♦
258519

It looks strange. Could you please edit your question and include more details such as 1) full exception including the stack trace (you can get it be calling the exception.ToString()). 2) SMTP communication log produced using a LogWriter property as described at http://www.rebex.net/kb/logging.aspx ?

(03 Mar '10, 21:39) Martin Vobr ♦♦

It turned out the attachments you were using were truly massive (like 1GB). Because attachment data was kept in memory, this caused OutOfMemoryException.

(21 May '10, 13:17) Lukas Pokorny ♦♦

It turned out the attachments you were using were truly massive (like 1GB). Because attachment data was kept in memory, this caused OutOfMemoryException sooner or later.

Since Rebex Mail 1.0.3793.0, it is possible to save or send mail messages with attachments of unlimited length using the following code:

// create an e-mail
MailMessage mail = new MailMessage();
...

Attachment attachment = new Attachment();
attachment.Options |= MimeOptions.DoNotPreloadAttachments; // <-- this is new
attachment.SetContentFromFile(attachmentPath);
mail.Attachments.Add(attachment);

// save the e-mail
mail.Save(path);

// send the e-mail
Smtp smtp = new Smtp();
smtp.Connect("server01");
smtp.Options |= SmtpOptions.SendWithNoBuffer; // <-- this is new
smtp.Send(mail);

At the moment, this doesn't work when the e-mail needs to be signed or encrypted – in that case, the content is still read into memory.

link

answered 21 May '10, 13:23

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.4k28
accept rate: 31%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×25
×19
×9

Asked: 03 Mar '10, 19:11

Seen: 646 times

Last updated: 23 Mar '11, 03:22