Jump to content

FSC

Newbies
  • Posts

    3
  • Joined

  • Last visited

Everything posted by FSC

  1. I will check that out but strangely that is working because I have checked the numbers, worst case it would come back as 0 and the routine would delete too many messages...
  2. I don't get any errors when I step through using the debugger and if I let it run my logs show it completes but then I open up the web based mail client and the total number of messages has only gone down by whatever I set the initial fetch to. I was simply going in and deleting the old messages manually but this is an ongoing process and I wanted to add a delete function to the main script so after it has read the recent new messages it can delete some of the older messages and keep the overall mailbox size down to a reasonable level. The other reason I want to have the script clear the old mail is that I got lazy and let it grow until my available mailbox space got too low and now I've got over 20,000 messages to delete, a slow process when each page of the web client only shows 200 max. In the end I want to keep several months of messages in the mailbox and between 75 and 125 new messages come in daily so each day when the script runs it would be great to have it keeping the mailbox up to date which I suspect will be around 3000 messages. Here is the current script (after the EmailConnectIMAP script and followed by EmailDisconnect) Go to Layout [ “EmailSettings” (EmailSettings) ] Set Variable [ $ViewedMessages; Value:EmailGetMessageCount( "Viewed:True" ) ] Set Variable [ $MessageBufferCount; Value:EmailSettings::BufferMessageCount ] (set to 3000) Set Variable [ $MaxFetch; Value:EmailSettings::Max Fetch ] (set to 200) Set Variable [ $MessagesLeftToDelete; Value:$ViewedMessages - $MessageBufferCount ] Set Field [ EmailSettings::_result; EmailReadMessages( "progress=" & EmailSettings::Progress Bar; "mailbox=INBOX" ; "Max=" & $MaxFetch; "attachments=false" ; "viewed=true" ; "deleted=false" ) ] #pulled the following from Max= & EmailSettings::Max Fetch for testing Commit Records/Requests [ No dialog ] If [ EmailSettings::_result = "ERROR" ] Set Field [ EmailSettings::_dialog; "Could not read messages: " & EmailLastError ] Go to Layout [ “EmailLog” (EmailLog) ] New Record/Request Set Field [ EmailLog::Desc; "An error occurred: " & EmailLastError & "¶¶" & "Version: " & EmailVersion ] Halt Script End If #loop through messages pulling in groups of maxfetch Loop #Loop over the messages, mark each as deleted Loop Exit Loop If [ $$NewMessagesCount > $MaxFetch ] Set Variable [ $Result; Value:EmailGetNextMessage ] Set Variable [ $Result; Value:EmailMessageSetFlag("deleted") ] Set Variable [ $$NewMessagesCount; Value:$$NewMessagesCount + 1 ] End Loop Set Variable [ $MessagesDeleted; Value:$MessagesDeleted + $MaxFetch ] Set Variable [ $MessagesLeftToDelete; Value:$MessagesLeftToDelete - $MaxFetch ] Exit Loop If [ $MessagesLeftToDelete < 1 ] Set Field [ EmailSettings::_result; EmailReadMessages( "progress=" & EmailSettings::Progress Bar; "mailbox=INBOX" ; "Max=" & $MaxFetch; "attachments=false" ; "viewed=true" ; "deleted=false" ) ] End Loop Set Field [ EmailSettings::Skip; EmailSettings::Skip - $MessagesDeleted ] Go to Record/Request/Page [ First ] Commit Records/Requests [ No dialog ]
  3. I have an email account I’m pulling unread messages from without issue but it has grown to have over 30,000 old messages so I’m trying to write a script to delete the read messages. The issue is that I obviously can’t pull all the read messages at once so I created a set of loops one inside the other, I fetch 200 messages then loop through them and flag them as deleted. Then I fetch another 200 and loop around to delete those. The first 200 get deleted but no more after that. Do I need to disconnect and reconnect before each new fetch?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.