public static MailboxNameData.Parsed Parse(this MailboxNameData target) { var modelStateDictionary = new System.Web.Http.ModelBinding.ModelStateDictionary(); MailboxName parsed0 = null; if (!MailboxName.IsEmpty(target.MailboxName)) { System.Collections.Generic.IReadOnlyCollection <string> parsed0Errors; if (!MailboxName.TryParse(target.MailboxName, out parsed0, out parsed0Errors)) { var modelState = new System.Web.Http.ModelBinding.ModelState(); foreach (var errorMessage in parsed0Errors) { modelState.Errors.Add(errorMessage); } modelStateDictionary.Add("MailboxName", modelState); } } else { var modelState = new System.Web.Http.ModelBinding.ModelState(); modelState.Errors.Add("Value required"); modelStateDictionary.Add("MailboxName", modelState); } if (!modelStateDictionary.IsValid) { throw new Fifthweek.Api.Core.ModelValidationException(modelStateDictionary); } return(new MailboxNameData.Parsed( parsed0)); }
public Parsed( MailboxName mailboxName) { if (mailboxName == null) { throw new ArgumentNullException("mailboxName"); } this.MailboxName = mailboxName; }
public async Task ExecuteAsync(MailboxName mailboxName, string subject, string body) { mailboxName.AssertNotNull("mailboxName"); subject.AssertNotNull("subject"); body.AssertNotNull("body"); var email = new EndToEndTestEmail(mailboxName.Value, subject, body, DateTime.UtcNow); using (var connection = this.connectionFactory.CreateConnection()) { await connection.UpsertAsync(email, EndToEndTestEmail.Fields.Subject | EndToEndTestEmail.Fields.Body | EndToEndTestEmail.Fields.DateReceived); } }
public Task SendEmailAsync(MailAddress from, string to, string subject, string message) { to.AssertNotNull("to"); subject.AssertNotNull("subject"); message.AssertNotNull("message"); MailboxName mailboxName; if (to.EndsWith(Constants.TestEmailDomain) && MailboxName.TryParse(to.Split('@').FirstOrDefault(), out mailboxName)) { return(this.setLatestMessage.ExecuteAsync(mailboxName, subject, message)); } return(this.baseService.SendEmailAsync(from, to, subject, message)); }
/// <summary> /// Logic for moving mails /// </summary> /// <param name="context"></param> protected override void Execute(CodeActivityContext context) { // ****************** getting the input values ************************ ExchangeService objExchangeService = ObjExchangeService.Get(context); Item mail = Mail.Get(context); string mailboxName = MailboxName.Get(context); string folderName = FolderName.Get(context); //********** Logic to move a mail from a folder to another ************ FolderView view = new FolderView(10000); view.PropertySet = new PropertySet(BasePropertySet.IdOnly); view.PropertySet.Add(FolderSchema.DisplayName); view.Traversal = FolderTraversal.Deep; Mailbox mailbox = new Mailbox(mailboxName); FindFoldersResults findFolderResults = objExchangeService.FindFolders(new FolderId(WellKnownFolderName.MsgFolderRoot, mailbox), view); bool flag = false; foreach (Folder folder in findFolderResults) { //Searching for supplied folder into mailbox if (folder.DisplayName.Equals(folderName)) { PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, EmailMessageSchema.Subject, EmailMessageSchema.ParentFolderId); // Bind to the existing item by using the ItemId. EmailMessage beforeMessage = EmailMessage.Bind(objExchangeService, mail.Id, propSet); // Move the specified mail to the given folder beforeMessage.Move(folder.Id); flag = true; break; } } if (!flag) { throw new Exception("Supplied folder is not found"); } }
public override int GetHashCode() => 31 *ActorName.GetHashCode() + MailboxName.GetHashCode() + GetHashCode(Parameters) + Parent.GetHashCode() + Type.GetHashCode();