You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the below function to move the mails to a Destination Folder/mailbox
// moveEmail moves an email to the specified mailbox folder.
func moveEmail(c *client.Client, msg *imap.Message, destMailbox string) error {
// Check if the destination mailbox exists else create it
if _, err := c.Select(destMailbox, false); err != nil {
log.Printf("Destination mailbox not found: %v", err)
log.Printf("Creating destination mailbox: %s", destMailbox)
if err := c.Create(destMailbox); err != nil {
log.Printf("Error creating destination mailbox: %v", err)
return err
}
}
// Move the email from inbox to destination mailbox
seqSet := new(imap.SeqSet)
seqSet.AddNum(msg.Uid)
log.Printf("Moving email with UID: %d to %s", msg.Uid, destMailbox)
err := c.Move(seqSet, destMailbox)
if err != nil {
log.Printf("Error moving email: %v", err)
return err
}
return nil
}
However, the c.Move doesn't perform the action, the mails remain in the same Label (as they say in Gmail) / mailbox.
moveEmail function is called from another function as below:
// Move to the "Recognised" mailbox folder
if err := moveEmail(client, msg, "Recognised"); err != nil {
log.Printf("Error moving email: %v\n", err)
return err
}
Here msg is *imap.Message obtained as below
seqset := new(imap.SeqSet)
seqset.AddRange(1, inbox.Messages)
items := []imap.FetchItem{imap.FetchEnvelope, imap.FetchUid}
messages := make(chan *imap.Message, inbox.Messages)
if err := client.Fetch(seqset, items, messages); err != nil {
log.Fatal(err)
}
// Iterate through the list of messages and move them based on the subject
for msg := range messages {
// Contains some checks and then finally the call to moveEmails
}
The text was updated successfully, but these errors were encountered:
emersion
changed the title
Move doesn't move emails in Gmail IMAP
v1: move doesn't move emails in Gmail IMAP
Oct 4, 2023
I have the below function to move the mails to a Destination Folder/mailbox
However, the c.Move doesn't perform the action, the mails remain in the same Label (as they say in Gmail) / mailbox.
moveEmail function is called from another function as below:
Here msg is *imap.Message obtained as below
The text was updated successfully, but these errors were encountered: