Send transmits the composed message through the configured SMTP server and throws when it cannot deliver, so a run that continues is a run that sent. Receive reads from whichever incoming server is configured, IMAP or POP3. WithUnreadOnly limits it to the messages the server still has as unread, and WithMaxMessages caps how many one Receive fetches, taking the newest first. Both default to every message, which is what Receive has always done and, on a mailbox of any size, a great deal of downloading. The overload taking an out List<ReceivedEmail> hands the messages back in the same call. Each ReceivedEmail carries Subject, From, Body, HtmlBody, Received, MessageId, and Attachments, the filename of everything that came with it. Body is the plain text part and falls back to the html when the sender wrote no text part at all, which is common for transactional mail. Received is when the message was sent, in local time, and MessageId is how the same message is recognised across runs. SaveTo writes the attachments of every received message into a directory, creating it when it is not there, and ReceivedEmail.SaveTo does the same for one message, handing back a GPALFile for each file written. Once a message has been dealt with, MarkAsRead and Delete on the ReceivedEmail act on that one, and MarkAllAsRead and DeleteAll on the mail object act on everything Receive collected, in a single connection. Delete flags and expunges, so the message is gone rather than left flagged. Clear resets the envelope, to, cc, bcc, subject, body, and attachments, while keeping the server settings and the from address, since that is who you send as. ParseEmailAddresses is a static utility that parses a comma-separated string of addresses into a List<MailboxAddress>.
Marking or deleting as part of the fetch would consume mail a run never got to if it failed half way through. Call MarkAsRead once the workflow has finished with the message, so a failed run finds it unread and waiting next time. DeleteAll acts on what Receive collected rather than on the mailbox, so with a filter in front of it, it empties only what the workflow read.
POP has no notion of a read message, so WithUnreadOnly warns and fetches everything anyway, and marking and deleting need the IMAP identity a POP message does not carry. WithMaxMessages still applies. Use IMAP for any workflow that has to consume mail rather than only read it.
//Receive fills the message list and returns the mail object, so SaveTo and MarkAllAsRead can follow it in the same chain when the whole batch is treated alike. Per-message MarkAsRead and Delete open a connection each, so a loop over many messages is many logins; the MarkAllAsRead and DeleteAll pair do the same work in one. An attachment is written under the filename the sender chose, reduced to a filename first, so a name like ..\..\startup.cmd cannot write outside the directory you asked for. A file already in that directory is replaced.
// the mail object first, then the server settings and the envelope on it
IGPALMail mail = GPAL
// Only what has not been read, and never more than 25 at a time
IGPALMail mail = mail
mail
// Handle each one, and only then say it has been handled
foreach (ReceivedEmail email in received)
{
if (false == email
List<GPALFile> saved = email
foreach (GPALFile invoice in saved)
GPAL
$"Saved [{invoice
email
}
// Or take the lot and finish with it in one connection
mail
Showing off some plain text in these paragraphs eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Here you can find different accents and emphasis sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
This is a link and how it could look like bestlinkinthebeautifulworld. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Here's just some classic bold text adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam notBoldSecondbestlinkinthebeautifulworld illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Obcaecati, iste distinctio veritatis eligendi laboriosam adipisicing elit illo nostrum corporis at adipisicing elit libero vel voluptas? Expedita, adipisicing facere dolores voluptatem ad ab rem assumenda soluta!
Other cuple of colors in case we want to emphasize several ways adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam adipisicing elit illo nostrum corporis at voluptatem libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta! Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quod veniam, quam ad expedita laborum sed at voluptates culpa ipsam ut vel. Ullam temporibus a mollitia quod aliquam ratione exercitationem nesciunt.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta! Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quod veniam, quam ad expedita laborum sed at voluptates culpa ipsam ut vel. Ullam temporibus a mollitia quod aliquam ratione exercitationem nesciunt.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae quas consequuntur illo numquam assumenda autem exercitationem distinctio perspiciatis in natus. Eius dicta similique ipsam ipsa minima, nemo quae enim tempore.
GPAL
.CallIfNotFound(GenericCallIfNotFound)
.WithPublishToConsole();
//System.Drawing.Rectangle windowSize = new System.Drawing.Rectangle(10, 10, 1500, 1024);
// NOTE: we have to set browser = before we execute any steps
// this is due to the 'GenericCallIfNotFound' which might throw an exception, and BankScraper will not have the browser set when it calls scraper.Close()
// until the complete fluent line gets executed (meaning every step, meaning browser is not set until everything else succeeds)
browser = GPAL.Browser
.WithBrowserType(Enums.BrowserType.Chrome)
.WithProfileDataDirectory(ChromeProfileLocation)
.WithUseAutomationEngine(AutomationEngine.Selenium)
.WithWindowSize(new System.Drawing.Rectangle(0,0,1920,1080))
.ToGPALObject();