Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: SAVE MESSSAGE Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
loredano
Newbie
Newbie
Avatar

Joined: 11 April 2018
Location: Italy
Online Status: Offline
Posts: 15
Posted: 27 November 2018 at 12:09am | IP Logged Quote loredano

Hi,
We have a list of entity that contains also the mailmessage. Then after inserting the data of 500 mails in the database, we select the id, the name of the email, the destination folder, the messageid; put these data in a datareader and (while) for each element in the datareader we use the method Save of the object mail message found in the list. But after 420 iterations on datareader we obtain a mailbee exception of outofmemory.
Is better use smtp object and use submit to pickup folder for every item?

This a fragment of code.

while (dr.Read())
{
id = dr.GetInt64(0);
currmessage = lstMessages.FirstOrDefault(oe => oe.Id == id);
pathEml = dr["PathEml"].ToString();

try
{
   if (!currmessage.Msg.SaveMessage(pathEml))
   {
      messageSaved = false;
       break;
   }
}
}
.......................
Back to Top View loredano's Profile Search for other posts by loredano
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 27 November 2018 at 1:14am | IP Logged Quote Alex

Hi,

You need to free MailMessage objects (e.g assign to null all pointers to the MailMessage object in question) immediately after they are no longer needed. This is not just for MailBee, it's the standard approach of avoiding memory leaks.

I guess lstMessages holds all the pointers and grows to storing 500 fully built emails in memory at the same time.

try
{
   if (!currmessage.Msg.SaveMessage(pathEml))
   {
      messageSaved = false;
       break;
   }
   currmessage.Msg = null;
}


Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide