[help][pst -copy and delete]

Hello guys, my name is Leonardo.

I’m trying to open a PST file (old) and create a new pst file. (New)
I need to move all the emails that have been received over 30 days for the new .pst and delete this emails from the old pst.

I followed all the examples I found and got some results, but one pst file with 2GB or more, takes over 24 hours to complete the process.

Can someone please help me with any examples or even that has done similar task?

thank you in advance


Hi,


Thank you for writing to Aspose Support Team.

We are not sure if the operation should take this much time or not, as there are not comparison matrics available for this purpose. But if the total time taken is unusual as compare to your other PST files, then it seems to be some issue with the PST file. Thus, I request you to please share your sample PST file with us so that we can investigate the issue at our end and guide you. Also, please share your sample runnable code for our reference.
Hello thanks for the quick return.

What I need is:
Open a PST file with the size of 2GB, through all the messages (folders and sub-folders) filtering the messages received more than 30 days, and move these messages to a new PST and then delete the original PST.

The problem is:
This process takes more than 24 hours, making it impossible to project going to production.

The code I am using is in File attachment

"All the texts of comments are in portuguese Brazil", but looked the code, I'm try to use a recursive functions to loop through folder and subfolder and when the folder have Messages i use the messageInfoCollection to loop through the emais, check the DeliveryTime properties if Little or Equal a today minus 30, create the folder in pstNew and use AddMessage. after use DeleteChildItem and done, so go to the next loop.


Thank you

Hi,


We are currently testing this issue by running tests on sample PST files at our end. We want to know if the performance issue exists with other PSTs as well of the same size at your end? If the issue is specific to a particular PST, we may be in need of that sample PST file to investigate the issue at our end.

You may also try searching the PST for messages by Sent Date using the PersonalStorageQueryBuilder and check if it provides some improvement? Meanwhile, we are running different tests and shall share our feedback with you soon.

Q-) We want to know if the performance issue exists with other PSTs as well of the same size at your end?


A-) No i don’t tested with other PST files, for tests i get one PST example from production user, but i have others PST examples in production, but this have more than 2 gb size, i chose this with 2gb size because is the smaller size when i have.

Q-)You may also try searching the PST for messages by Sent Date using the PersonalStorageQueryBuilder and check if it provides some improvement?

A-) I have used Personal Storage QueryBuilder , see in the example code attachment in previous message,
and i don’t found differences between a simple IF and Personal Storage QueryBuilder the time is the same.


A really appreciate what you can do for me in this case, i waiting your feedback soon.

thanks

Hi,

Thank you for sharing the feedback.

I have reviewed your code sample and found that you are using pst.ExtractMessage two times in the ExtractMsgFiles. Please note that MapiMessage is quite a heavy class and this operation will need considerable time to extract message. For date comparison, please use the MessageInfo and PersonalStorage.ExtractProperty method. This should have improved performance. Please try it at your end and let us know your feedback.

Sample Code:
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves>false</w:TrackMoves>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–>

private static void ExtractMsgFiles(FolderInfo folderInfo, PersonalStorage pst, PersonalStorage pstNew)

{

MessageInfoCollection messageInfoCollection = folderInfo.GetContents();

foreach (MessageInfo messageInfo in messageInfoCollection)

{

//Don't use pst.ExtractMessage at this stage or in the "if" block

if (pst.ExtractProperty(messageInfo.EntryId, MapiPropertyTag.PR_DELIVER_TIME).GetDateTime() < DateTime.Now.AddDays(-1))

{

//Copy the file to new pst and delete from old pst

}

}

}

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

Thanks for your attention in analysis of my code example and show one solution.
I try to change my code to following your example (Replace ExtractMessage for ExtractProperty) and i have a better performance in execution, from 24 hours to 10 hours until the finish the execution.(Not is a good time for ends go to the production)

But in another case i tested other flow, copy the original pst file two times, and: in original pst file i delete the e-mails received more than 30 days
in first copy from original pst i keep for backup purpose
in second copy from original pst i delete the e-mails received until than 30 days.
This way have the same result.

Look the code in attachment:

Now basicly the loop is:
*******************************************************************************
foreach (MessageInfo messageInfo in messageInfoCollection)
{
if (pst.ExtractProperty(messageInfo.EntryId, MapiPropertyTag.PR_MESSAGE_DELIVERY_TIME).GetDateTime() <= DateTime.Now.AddDays((Convert.ToInt32(cmbDias.Text) * -1)))
{
//Grava algumas informaçóes de LOG
log.gravaLog("[LENDO-MSG-PST-TRABALHO]", "mensagem: " + messageInfo.Subject + "....", "");
log.gravaLog("[LENDO-MSG-PST-TRABALHO]", "Remetente:." + messageInfo.SenderRepresentativeName, "");
//Logar e Deletar a mensagem do folder antigo
log.gravaLog("[DELETANDO-MSG-PST-TRABALHO]", "Deletando Mensagem" + messageInfo.Subject + "....", Environment.NewLine);
folderInfo.DeleteChildItem(messageInfo.EntryId);
}
}

*******************************************************************************

but the process still remains slow and in some cases show this exception message:
Arithmetic operation resulted in an overflow ( Translated from Portuguese/BR message)

Maybe the problem in this case is a DeleteChildItem Method,
n other test i only copy (AddMessage to other pst) messages not use DeleteChildItem throw the same loop and i have a good performance.
Thanks

Hi,


Thank you for providing feedback.

devifc:
n other test i only copy (AddMessage to other pst) messages not use DeleteChildItem throw the same loop and i have a good performance.

Could you please explain how much performance gain is there while using this logic? What I have understood from this logic is that you create two PST and then copy all the messages older than 30 days in one PST and copy all other messages to the second PST. Once you explain this scenario, we will perform more tests and provide assistance accordingly.

We have tried to re-produce the issue of “Arithmetic operation resulted in an overflow” but it seems to be specific to the messages in a PST. This may require your sample PST for further analysis in this regard.