S22.Imap icon indicating copy to clipboard operation
S22.Imap copied to clipboard

Inline Images

Open Ladimaco opened this issue 7 years ago • 2 comments

I am working on an application that monitors emails, and saves photos from the emails to a server.

This is working fine for emails with attached images. But am running into a problem with images sent inline.

With inline images, I am itterating through the AlternateViews instead of attachments.

It looks like the first inline image is not contained in the alternate views, but the rest are? For example, I look at the email in a mail client, and see 8 images inline. The message being pulled from the server with my software, saves that last 7 images, but doesn't see the first one at all.

Any idea how I get this first inline image out of the email to be able to save it as well?

Any help is appreciated!

-Larry

Ladimaco avatar Jul 14 '17 19:07 Ladimaco

Hy, i'm really trying, but i can't download any. could you help me with a part of the code so i can download at least one image inline?

ademirMess avatar Aug 24 '20 17:08 ademirMess

Here is what I am using to do this...

` public void CheckMail(object source, ElapsedEventArgs e) { using (ImapClient imapClient = new ImapClient("imap.gmail.com", 993, "accountemail", "password", AuthMethod.Login, true, (RemoteCertificateValidationCallback)null)) { Console.WriteLine("We are connected!"); foreach (uint uid in imapClient.Search(SearchCondition.Unseen(), (string)null)) { MailMessage message = imapClient.GetMessage(uid, FetchOptions.Normal, true, (string)null); string subject = message.Subject; this.eventLog1.WriteEntry("Working on email with subject: " + subject, EventLogEntryType.Information, this.eventId++); if (!subject.ToUpper().Contains("special subject I am looking for")) { //Whatever you want to do if skipping this email imapClient.AddMessageFlags(uid, (string)null, new MessageFlag[1]); } else { if (message.Attachments.Count == 0 && message.AlternateViews.Count == 0) { //Whatever you want to do if processing this email imapClient.AddMessageFlags(uid, (string)null, new MessageFlag[1]); } //Code here to save the attachments.

                    imapClient.AddMessageFlags(uid, (string)null, new MessageFlag[1]);
                }
            }
            imapClient.Dispose();
        }
    }

`

Hope this helps

Ladimaco avatar Aug 24 '20 19:08 Ladimaco