-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moving emails in google (continuation of #68) #70
Comments
Also i sometimes get an exception after the email has arrived
It does not seem to recover, ie stops receiving emails at that point. I don't know if this is during the MoveAsync operation. What I see is that after the exception is logged I just get
It never does the other log message for the uniqueId result of the move operation. I'm guessing the exception gets logged immediately but the other log message is queueing up ro something ... |
Actually weirder than that. It does seem to have reconnected but it is not calling my Incoming method. So just seeing
but nothing else? |
I've fixed a bug where the source folder was null which might have caused the issues you found, try the latest pre-release. |
Ok thanks will try tomorrow morning. |
I upgraded to 2.11.5-tags-v2-11-5-rc0001 which I think is the latest version. I'm afraid it made no difference. I have followed the code through and we get to the following line in MailFolderClient.MoveOrCopyAsync (line 397)
after the loop dest is null. So the mail has not been moved. When i run through the code at start up - ie when the move is working, I see the destination folder is not open then either - in fact I cannot see at all what the difference is between the 2 cases .... |
so is htis not the latest 2.11.5-tags-v2-11-5-rc0001 ?? (it was the latest according to nuget) anyhow i wil take a look a bit later in case my investigation missed out a bit ... |
That is the latest. Not sure why line 397 doesn't match what's on here though. |
Ok I realised I am looking at the code in my IDE which has been decompiled and looks somewhat different to the source code. So the line I referenced above where it went off into MailKit code is actually line 318 in your source code ... sorry for the confusion. |
So it's still not working then? I've tested it on Gmail and it was working for me. |
I looked at your profile and it seems you are based in HK. Do you ever sleep? anyway thanks for your continued help on this, I will look at your test tomorrow I have probably done something simple wrong ... us old people do need a bit of down time! |
Ok I updated to the latest copy of your code. I tried to bring my mail monitor in line with your code in MonitorMoveAsync.
The end result is
Difficult to get my head round this! |
I was considering just moving to the gmail api for processing these incoming mails. Have you ever tried that, do you have any advice? |
I was also thinking of a) polling every few minuted=s and processing the emails, or b) deleting them after receiving rather than trying to move them. the move was intended as a belt and braces while we get everything up and running in case we decide we need to go and look at the original emails for some reason. but obviously the first approach would be preferable ... |
ok deleting after downloading is working. This is not ideal but I can progress with some other stuff that has got a bit held up. I would be interested if you could extend your test to involve more emails with a greater time between as that seemed to make a difference in my testing. |
Thanks for testing that, I should be able to get it to fail on my end too now so I can investigate it. In the meantime, have you tried copying before deleting? An even simpler workaround for an unmonitored mailbox would be to just label it as read, or if it is monitored you could use flags. I'll see if I can figure out what's going on here too though as I used to use it when I had a client who wanted it. |
I was caching the source mail folder, but now that I've stopped doing that the issue you found appears to be resolved. Please close this thread if that's the case. |
Ok we have to take grandchildren out for the day today but I will retest first thing tomorrow (Wednesday). |
I've fixed the folder issue with messageSummary, so this is now safe to use: |
I pulled your latest version. All appeared fine in testing this morning - it processed a couple of emails sitting in the inbox, then a few more i sent over the next 10 mintes. However when I sent another email almost 3 hours later I got the exception seen below. I have included the last successful read and move at 11:53
|
Glad to hear the emails are moving fine now, I'll close this move issue then. I've made a new issue for the disconnection after 3 hours. |
Dan. I raised an issue last month and you apparently fixed it really quickly (thanks). Unfortunately i still have a problem - don't know if I didn't test it properly but that is probably the case. You did some stuff to enable creating folders (aka labels) in google mail then to move an email using
var uniqueId = await mailFolderClient.MoveToAsync(messageSummary, destinationFolderFullName,
This works when i first start the monitor - all emails currently sitting in the inbox are delivered to the monitor, stored locally then moved to the Processed folder on GoogleMail. But when a new email arrives in the inbox this does not happen - the above code returns null rather than a uniqueId. My monitor code looks like the following (have taken out the stuff related to my processing of the emails)
using MailKit;
using MailKitSimplified.Receiver.Abstractions;
using MailKitSimplified.Receiver.Extensions;
using MimeKit;
namespace Caa.Api.Email;
public class MailMonitor : BackgroundService
{
private const string processedFolder = "Processed";
}
2024-07-30 11:38:13.3175 [DEBUG] Caa.Api.Email.MailMonitor: Incoming testing 1 2 3
2024-07-30 11:39:12.0670 [DEBUG] Caa.Api.Email.MailMonitor: After arrival move return uniqueId: 37
2024-07-30 11:39:24.0752 [ INFO] Caa.Api.Email.MailMonitor: Departing testing 1 2 3
2024-07-30 11:41:13.3175 [DEBUG] Caa.Api.Email.MailMonitor: Incoming testing 0 1 2
2024-07-30 11:41:12.0670 [DEBUG] Caa.Api.Email.MailMonitor: After arrival move return uniqueId: null
The text was updated successfully, but these errors were encountered: