Skip to content

Instantly share code, notes, and snippets.

@jonfuller
Last active April 11, 2018 00:45
Show Gist options
  • Save jonfuller/710b806640ffa5cbb886478ed7d01729 to your computer and use it in GitHub Desktop.
Save jonfuller/710b806640ffa5cbb886478ed7d01729 to your computer and use it in GitHub Desktop.
Blog - Email Interface - Mail Processor
// snip
var handlers = new IMailProcessor[]
{
new AppleHealthAttachmentMailProcessor(from, settings, customSheets),
new AppleHealthGoogleDriveMailProcessor(from, settings, customSheets),
new SettingsUpdateMailProcessor(from, settingsStore),
new HelpMailProcessor(from), // <-- catch all
};
try
{
return handlers
.First(h => h.CanHandle(originalEmail, attachments))
.Process(originalEmail, attachments);
}
catch (Exception e)
{
return Result.Failure(MailUtility.ConstructErrorMessage(originalEmail, from, e), e);
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment