Esempio n. 1
0
        private List <Appointment> GetAppointments(ExchangeService service, List <AttendeeInfo> rooms, DateTime from, DateTime to)
        {
            List <Appointment>  appointments = new List <Appointment>();
            List <AttendeeInfo> attend       = new List <AttendeeInfo>();

            foreach (AttendeeInfo inf in rooms)
            {
                FolderId folderid = new FolderId(WellKnownFolderName.Calendar, new Mailbox(inf.SmtpAddress));
                FindItemsResults <Appointment> aps = service.FindAppointments(folderid, new CalendarView(from, to)).Result;
                appointments.AddRange(aps.Items.ToList());
            }

            return(appointments);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an instance with all values
        /// </summary>
        /// <param name="id">Attribution id</param>
        /// <param name="sourceId">Source Id</param>
        /// <param name="displayName">Display name</param>
        /// <param name="isWritable">Whether writable</param>
        /// <param name="isQuickContact">Wther quick contact</param>
        /// <param name="isHidden">Whether hidden</param>
        /// <param name="folderId">Folder id</param>
        public Attribution(string id, ItemId sourceId, string displayName, bool isWritable, bool isQuickContact, bool isHidden, FolderId folderId)
            : this()
        {
            EwsUtilities.ValidateParam(id, "id");
            EwsUtilities.ValidateParam(displayName, "displayName");

            this.Id             = id;
            this.SourceId       = sourceId;
            this.DisplayName    = displayName;
            this.IsWritable     = isWritable;
            this.IsQuickContact = isQuickContact;
            this.IsHidden       = isHidden;
            this.FolderId       = folderId;
        }
Esempio n. 3
0
 /// <summary>
 /// Copies items in the specified conversation to a specific folder. Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="contextFolderId">The Id of the folder items must belong to in order to be copied. If contextFolderId
 /// is null, items across the entire mailbox are copied.</param>
 /// <param name="destinationFolderId">The Id of the destination folder.</param>
 void CopyItemsInConversation(
     FolderId contextFolderId,
     FolderId destinationFolderId)
 {
     this.Service.CopyItemsInConversations(
         new MapEntry <ConversationId, DateTime?>[]
     {
         new MapEntry <ConversationId, DateTime?>(
             this.Id,
             this.GlobalLastDeliveryTime)
     },
         contextFolderId,
         destinationFolderId)[0].ThrowIfNecessary();
 }
Esempio n. 4
0
            public FindItemsResults <Item> SetFolder(FindItemsResults <Item> EmailFolder, string FolderName, ExchangeService service, SearchFilter.IsEqualTo sf, string EmailAddress, string MappedMailboxAddress, Int32 ItemsAmount = 1)
            {
                FindFoldersResults Subfolders = null;

                if (FolderName == "inbox")
                {
                    FolderId folderToAccess = new FolderId(WellKnownFolderName.Inbox, EmailAddress);

                    if (MappedMailboxAddress != "")
                    {
                        folderToAccess = new FolderId(WellKnownFolderName.Inbox, MappedMailboxAddress);
                    }


                    if (sf != null)
                    {
                        EmailFolder = service.FindItems(folderToAccess, sf, new ItemView(ItemsAmount));
                    }
                    else
                    {
                        EmailFolder = service.FindItems(folderToAccess, new ItemView(ItemsAmount));
                    }
                }
                else
                {
                    Subfolders = service.FindFolders(WellKnownFolderName.Inbox, new FolderView(int.MaxValue));

                    foreach (var subfolder in Subfolders.Folders)
                    {
                        if (FolderName == subfolder.DisplayName.ToLower())
                        {
                            if (sf != null)
                            {
                                EmailFolder = service.FindItems(subfolder.Id, sf, new ItemView(ItemsAmount));
                            }
                            else
                            {
                                EmailFolder = service.FindItems(subfolder.Id, new ItemView(ItemsAmount));
                            }
                            Subfolders = null;
                            break;
                        }
                    }

                    Subfolders = null;
                }


                return(EmailFolder);
            }
Esempio n. 5
0
 /// <summary>
 /// Deletes items in the specified conversation.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="contextFolderId">The Id of the folder items must belong to in order to be deleted. If contextFolderId is
 /// null, items across the entire mailbox are deleted.</param>
 /// <param name="deleteMode">The deletion mode.</param>
 void DeleteItems(
     FolderId contextFolderId,
     DeleteMode deleteMode)
 {
     this.Service.DeleteItemsInConversations(
         new MapEntry <ConversationId, DateTime?>[]
     {
         new MapEntry <ConversationId, DateTime?>(
             this.Id,
             this.GlobalLastDeliveryTime)
     },
         contextFolderId,
         deleteMode)[0].ThrowIfNecessary();
 }
Esempio n. 6
0
        public static EWSAppointmentInfo[] AppointmentsInfoWeek(string mailbox)
        {
            ServicePointManager.ServerCertificateValidationCallback =
                delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
            {
                // Replace this line with code to validate server certificate.
                return(true);
            };

            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);

            if (string.IsNullOrEmpty(HAP.Web.Configuration.hapConfig.Current.SMTP.Exchange))
            {
                service.AutodiscoverUrl(HAP.Web.Configuration.hapConfig.Current.SMTP.ImpersonationUser, (string redirectionUrl) => { return(true); });
            }
            else
            {
                service.Url = new Uri("https://" + HAP.Web.Configuration.hapConfig.Current.SMTP.Exchange + "/ews/exchange.asmx");
            }

            if (string.IsNullOrEmpty(HAP.Web.Configuration.hapConfig.Current.SMTP.ImpersonationDomain))
            {
                service.Credentials = new WebCredentials(HAP.Web.Configuration.hapConfig.Current.SMTP.ImpersonationUser, HAP.Web.Configuration.hapConfig.Current.SMTP.ImpersonationPassword);
            }
            else
            {
                service.Credentials = new WebCredentials(HAP.Web.Configuration.hapConfig.Current.SMTP.ImpersonationUser, HAP.Web.Configuration.hapConfig.Current.SMTP.ImpersonationPassword, HAP.Web.Configuration.hapConfig.Current.SMTP.ImpersonationDomain);
            }

            FolderId fid = new FolderId(WellKnownFolderName.Calendar, new Mailbox(mailbox));
            List <EWSAppointmentInfo> s = new List <EWSAppointmentInfo>();

            foreach (Appointment a in service.FindAppointments(fid, new CalendarView(DateTime.Now, DateTime.Now.AddDays(14))))
            {
                s.Add(new EWSAppointmentInfo {
                    Start = a.Start.ToString(), End = a.End.ToString(), Location = a.Location, Subject = a.Subject
                });
                try
                {
                    a.Load();
                    string b = a.Body.Text;
                    Regex  r = new Regex("<html>(?:.|\n|\r)+?<body>", RegexOptions.IgnoreCase);
                    b = r.Replace(b, "");
                    b = new Regex("</body>(?:.|\n|\r)+?</html>(?:.|\n|\r)+?", RegexOptions.IgnoreCase).Replace(b, "");
                    s.Last().Body = b;
                }
                catch { }
            }
            return(s.ToArray());
        }
Esempio n. 7
0
        private static ExtendedPropertyDefinition Prop_PR_FOLDER_TYPE = new ExtendedPropertyDefinition(0x3601, MapiPropertyType.Integer);          // PR_FOLDER_TYPE 0x3601 (13825)

        public static bool GetFolderPath(ExchangeService oExchangeService, FolderId oFolderId, ref string sFolderPath)
        {
            bool   bRet    = false;
            Folder oFolder = null;

            PropertySet oPropertySet = new PropertySet(BasePropertySet.IdOnly, Prop_PR_FOLDER_PATH);

            oExchangeService.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID
            oFolder = Folder.Bind(oExchangeService, oFolderId, oPropertySet);

            bRet = GetFolderPath(oFolder, ref sFolderPath);

            return(bRet);
        }
Esempio n. 8
0
 public static void CreateLotsOfMessages(ExchangeService exchService, FolderId folderId)
 {
     for (var x = 0; x < NumberOfMessagesToCreate; x++)
     {
         var msg = new EmailMessage(exchService);
         msg.Subject = "SearchingMailboxViaEWS message " + x.ToString("D5");
         msg.Body    = new TextBody {
             BodyType = BodyType.Text, Text = "Test."
         };
         msg.SetExtendedProperty(MyNamedProp, x);
         msg.Save(folderId);
         Console.WriteLine("Created message " + x + " of " + NumberOfMessagesToCreate);
     }
 }
        public questStatus Delete(DbMgrTransaction trans, FolderId folderId)
        {
            // Initialize
            questStatus status = null;


            // Delete all filterFolders in this table.
            status = _dbFilterFoldersMgr.Delete(trans, folderId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Esempio n. 10
0
 /// <summary>
 /// Sets the read state of items in the specified conversation. Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="contextFolderId">The Id of the folder items must belong to in order for their read state to
 /// be set. If contextFolderId is null, the read states of items across the entire mailbox are set.</param>
 /// <param name="isRead">if set to <c>true</c>, conversation items are marked as read; otherwise they are
 /// marked as unread.</param>
 void SetReadStateForItemsInConversation(
     FolderId contextFolderId,
     bool isRead)
 {
     this.Service.SetReadStateForItemsInConversations(
         new MapEntry <ConversationId, DateTime?>[]
     {
         new MapEntry <ConversationId, DateTime?>(
             this.Id,
             this.GlobalLastDeliveryTime)
     },
         contextFolderId,
         isRead)[0].ThrowIfNecessary();
 }
Esempio n. 11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (FolderId.Length != 0)
            {
                hash ^= FolderId.GetHashCode();
            }
            if (createdAt_ != null)
            {
                hash ^= CreatedAt.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            hash ^= Labels.GetHashCode();
            if (NetworkId.Length != 0)
            {
                hash ^= NetworkId.GetHashCode();
            }
            if (ZoneId.Length != 0)
            {
                hash ^= ZoneId.GetHashCode();
            }
            hash ^= v4CidrBlocks_.GetHashCode();
            hash ^= v6CidrBlocks_.GetHashCode();
            if (RouteTableId.Length != 0)
            {
                hash ^= RouteTableId.GetHashCode();
            }
            if (dhcpOptions_ != null)
            {
                hash ^= DhcpOptions.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            string       myAddress  = "*****@*****.**";
            SecureString myPassword = new NetworkCredential("", "MYPASSWORD").SecurePassword; // Example. Use a better way to get your password!

            // Using Microsoft.Identity.Client 4.22.0
            // Configure the MSAL client to get tokens
            var pcaOptions = new PublicClientApplicationOptions
            {
                ClientId = ConfigurationManager.AppSettings["clientId"],
                TenantId = ConfigurationManager.AppSettings["tenantId"]
            };

            var pca = PublicClientApplicationBuilder
                      .CreateWithApplicationOptions(pcaOptions).Build();


            // The permission scope required for EWS access
            var ewsScopes = new string[] { "https://outlook.office365.com/EWS.AccessAsUser.All" };

            var authResult = await pca.AcquireTokenByUsernamePassword(ewsScopes, myAddress, myPassword).ExecuteAsync();

            var token = authResult.AccessToken;

            ExchangeService ews = new ExchangeService();

            ews.Credentials = new OAuthCredentials(token);

            ews.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");


            // Sending Mail
            EmailMessage email = new EmailMessage(ews);

            email.ToRecipients.Add("*****@*****.**");
            email.Subject = "HelloWorld";
            email.Body    = new MessageBody("This is the first email I've sent by using the EWS Managed API");
            email.Send();

            // Receiving Mail
            FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox, myAddress);
            ItemView itemView      = new ItemView(1000);
            var      mails         = ews.FindItems(SharedMailbox, itemView);

            foreach (var mail in mails)
            {
                Console.WriteLine(mail.Subject);
            }
        }
Esempio n. 13
0
        internal static FindItemsResults <Appointment> LoadResouceCallendar(string ResourceName)
        {
            ExchangeService service = ExchangeHelper.GetExchangeServiceConnection();

            PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
            ExtendedPropertyDefinition PidTagWlinkAddressBookEID = new ExtendedPropertyDefinition(0x6854, MapiPropertyType.Binary);
            ExtendedPropertyDefinition PidTagWlinkFolderType     = new ExtendedPropertyDefinition(0x684F, MapiPropertyType.Binary);

            psPropset.Add(PidTagWlinkAddressBookEID);
            psPropset.Add(PidTagWlinkFolderType);

            NameResolutionCollection resolve = service.ResolveName(ResourceName, ResolveNameSearchLocation.DirectoryOnly, false, psPropset);

            FindItemsResults <Appointment> findResults = null;

            if (resolve.Count > 0)
            {
                try{
                    FolderId       SharedCalendarId = new FolderId(WellKnownFolderName.Calendar, resolve[0].Mailbox.Address);
                    CalendarFolder cf = CalendarFolder.Bind(service, SharedCalendarId);
                    findResults = LoadResouceCallendar(cf);
                }
                catch (Microsoft.Exchange.WebServices.Data.ServiceResponseException ex)
                {
                    Trace.TraceError("Error reading calendar for resource {0} ErrMsg: {1}", ResourceName, ex.Message);
                    throw ex;
                }
                //Folder SharedCalendaFolder = Folder.Bind(service, SharedCalendarId);
            }
            else
            {
                throw new ApplicationException(String.Format("Error resolving resource name in GAL: {0}", ResourceName));
            }



            if (findResults != null && findResults.TotalCount > 0)
            {
                service.LoadPropertiesForItems(from Item item in findResults select item,
                                               new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Start, AppointmentSchema.End,
                                                               AppointmentSchema.Location, AppointmentSchema.Subject, AppointmentSchema.Categories, OnlineMeetingExternalLink));
            }

            return(findResults);


            /*  PropertySet props = new PropertySet();
             * CalendarFolder.Bind(service,WellKnownFolderName.Calendar,)*/
        }
Esempio n. 14
0
    /// <summary>
    /// Binds to an existing user configuration and loads the specified properties.
    /// Calling this method results in a call to EWS.
    /// </summary>
    /// <param name="service">The service to which the user configuration is bound.</param>
    /// <param name="name">The name of the user configuration.</param>
    /// <param name="parentFolderId">The Id of the folder containing the user configuration.</param>
    /// <param name="properties">The properties to load.</param>
    /// <returns>A user configuration instance.</returns>
    static UserConfiguration Bind(
        ExchangeService service,
        String name,
        FolderId parentFolderId,
        UserConfigurationProperties properties)
    {
        UserConfiguration result = service.GetUserConfiguration(
            name,
            parentFolderId,
            properties);

        result.isNew = false;

        return(result);
    }
Esempio n. 15
0
        public questStatus Delete(DbMgrTransaction trans, FolderId folderId)
        {
            // Initialize
            questStatus status = null;


            // Perform delete in this transaction.
            status = delete((MasterPricingEntities)trans.DbContext, folderId);
            if (!questStatusDef.IsSuccess(status))
            {
                RollbackTransaction(trans);
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Esempio n. 16
0
 private questStatus delete(MasterPricingEntities dbContext, FolderId parentFolderId)
 {
     try
     {
         dbContext.FilterFolders.RemoveRange(dbContext.FilterFolders.Where(r => r.FolderId == parentFolderId.Id));
         dbContext.SaveChanges();
     }
     catch (System.Exception ex)
     {
         return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                              this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                              ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
     }
     return(new questStatus(Severity.Success));
 }
Esempio n. 17
0
        private void CreateContactsFolder(ExchangeService svc, string folderName, FolderId folderId)
        {
            ContactsFolder folder = new ContactsFolder(svc);

            folder.DisplayName = folderName;

            try
            {
                folder.Save(folderId);
            }
            catch (Exception erro)
            {
                ValidationCreationFolderException(erro);
            }
        }
Esempio n. 18
0
        private void DisplayFolder(FolderId folderId)
        {
            _CurrentService.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID
            Folder oFolder = Folder.Bind(
                _CurrentService,
                folderId,
                _CurrentDetailPropertySet);

            FolderContentForm.Show(
                string.Format(DisplayStrings.TITLE_CONTENTS_FOLDER, oFolder.DisplayName),
                oFolder,
                ItemTraversal.Shallow,
                _CurrentService,
                this);
        }
        public void sendMessageToGraduates(string toMail, string subject, string htmlText)
        {
            EmailMessage email = new EmailMessage(service);

            email.From = UserEmail;
            email.ToRecipients.Add(toMail);
            email.Subject       = subject;
            email.Body          = new MessageBody(htmlText);
            email.Body.BodyType = BodyType.HTML;

            var userMailbox = new Mailbox("*****@*****.**");
            var folderId    = new FolderId(WellKnownFolderName.SentItems, userMailbox);

            email.SendAndSaveCopy(folderId);
        }
Esempio n. 20
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (FolderId.Length != 0)
            {
                hash ^= FolderId.GetHashCode();
            }
            if (createdAt_ != null)
            {
                hash ^= CreatedAt.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            hash ^= Labels.GetHashCode();
            if (StorageSize != 0L)
            {
                hash ^= StorageSize.GetHashCode();
            }
            if (DiskSize != 0L)
            {
                hash ^= DiskSize.GetHashCode();
            }
            hash ^= productIds_.GetHashCode();
            if (Status != global::Yandex.Cloud.Compute.V1.Snapshot.Types.Status.Unspecified)
            {
                hash ^= Status.GetHashCode();
            }
            if (SourceDiskId.Length != 0)
            {
                hash ^= SourceDiskId.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        /// <summary>
        /// Show the form and default to the given folder.
        /// </summary>
        /// <param name="caption">Form caption to display</param>
        /// <param name="service">ExchangeService to use when making calls.</param>
        /// <param name="folder">Folder to display events from by default</param>
        public static void Show(string caption,
                                FolderId folderId,
                                ExchangeService service)
        {
            PullNotificationForm diag = new PullNotificationForm();

            // Only try to populate CurrentFolderId if we were passed a value
            if (folderId != null)
            {
                diag.SetAndDisplayFolderId(folderId);
            }
            diag.Text           = caption.Length == 0 ? "''" : caption;
            diag.CurrentService = service;

            diag.Show();
        }
Esempio n. 22
0
        public questStatus Read(DbMgrTransaction trans, FolderId folderId, out List <Quest.Functional.MasterPricing.Filter> filterList)
        {
            // Initialize
            questStatus status = null;

            filterList = null;


            // Read filter
            status = _dbFiltersMgr.Read(trans, folderId, out filterList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Esempio n. 23
0
 /// <summary>
 /// Sets the retention policy of items in the specified conversation. Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="contextFolderId">The Id of the folder items must belong to in order for their retention policy to
 /// be set. If contextFolderId is null, the retention policy of items across the entire mailbox are set.</param>
 /// <param name="retentionPolicyType">Retention policy type.</param>
 /// <param name="retentionPolicyTagId">Retention policy tag id.  Null will clear the policy.</param>
 void SetRetentionPolicyForItemsInConversation(
     FolderId contextFolderId,
     RetentionType retentionPolicyType,
     Guid?retentionPolicyTagId)
 {
     this.Service.SetRetentionPolicyForItemsInConversations(
         new MapEntry <ConversationId, DateTime?>[]
     {
         new MapEntry <ConversationId, DateTime?>(
             this.Id,
             this.GlobalLastDeliveryTime)
     },
         contextFolderId,
         retentionPolicyType,
         retentionPolicyTagId)[0].ThrowIfNecessary();
 }
Esempio n. 24
0
        private static FolderId GetFolder(ExchangeConfigurationCredentials credentials, WellKnownFolderName folder)
        {
            FolderId result;
            var      emailAddressValidator = new EmailAddressAttribute();

            if (emailAddressValidator.IsValid(credentials.ExchangeName))
            {
                var mailBox = new Mailbox(credentials.ExchangeName);
                result = new FolderId(folder, mailBox);
            }
            else
            {
                result = new FolderId(folder);
            }
            return(result);
        }
Esempio n. 25
0
        private void CreateNotesFolder(ExchangeService svc, string folderName, FolderId folderId, string folderClass)
        {
            Folder folder = new Folder(svc);

            folder.DisplayName = folderName;
            folder.FolderClass = folderClass;

            try
            {
                folder.Save(folderId);
            }
            catch (Exception erro)
            {
                ValidationCreationFolderException(erro);
            }
        }
Esempio n. 26
0
    private void CreateSubscription()
    {
        var ids = new FolderId[2] {
            new FolderId(WellKnownFolderName.Root), new FolderId(WellKnownFolderName.Inbox)
        };
        var events = new List <EventType>();

        events.Add(EventType.NewMail);
        if (_subscription != null)
        {
            ((StreamingSubscription)_subscription).Unsubscribe();
            _connection.RemoveSubscription((StreamingSubscription)_subscription);
        }
        _subscription = _exchange.SubscribeToStreamingNotifications(ids, events.ToArray());
        _connection.AddSubscription((StreamingSubscription)_subscription);
    }
        public ActionResult Read(FilterFolderViewModel viewModel)
        {
            // Initialize
            questStatus        status             = null;
            UserMessageModeler userMessageModeler = null;

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Log Operation
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = LogOperation();
            if (!questStatusDef.IsSuccess(status))
            {
                userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Authorize
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = Authorize(viewModel._ctx);
            if (!questStatusDef.IsSuccess(status))
            {
                userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Get filter folders
            *---------------------------------------------------------------------------------------------------------------------------------*/
            FolderId folderId = new FolderId(viewModel.Id);
            FilterFolderViewModel filterFolderViewModel = null;
            FilterFolderModeler   filterFolderModeler   = new FilterFolderModeler(this.Request, this.UserSession);

            status = filterFolderModeler.Read(viewModel, out filterFolderViewModel);
            if (!questStatusDef.IsSuccess(status))
            {
                userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Return data.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = new questStatus(Severity.Success);
            filterFolderViewModel.questStatus = status;
            return(Json(filterFolderViewModel, JsonRequestBehavior.AllowGet));
        }
        private bool Procesar(Item item)
        {
            bool respuesta = false;

            try
            {
                item.Load();                         //cargamos el resto del mensaje.
                MessageBody messageBody = item.Body; //obtenemos el Body del mensaje

                //DeleteMode.HardDelete Eliminamos completamente el item.
                //DeleteMode.MoveToDeletedItems Movemos el item a la carpeta de eliminados
                //DeleteMode.SoftDelete Depende de ExchangeVersion, pero principalmente permite la recuperacion del item despues de eliminado.

                if (item.HasAttachments)//si tiene adjuntos
                {
                    ProcesarAdjuntos(item);
                }
                else
                if (item.Subject.ToLower().Contains("eliminar") || messageBody.Text.ToLower().Contains("eliminar")) // Revisamos si el asunto o en el body contiene la palabra "eliminar"
                {
                    item.Delete(DeleteMode.HardDelete);                                                             //Eliminamos completamente el item.
                    respuesta = true;
                    Console.WriteLine("Item Eliminado.");
                }
                else if (item.Subject.ToLower().Contains("mover") || messageBody.Text.ToLower().Contains("mover")) // Revisamos si el asunto o en el body contiene la palabra "mover"
                {
                    FolderId folderID = getFolderID("procesados");

                    if (folderID != null)    //si encontramos la carpeta la
                    {
                        item.Move(folderID); //movemos el item.
                        respuesta = true;
                        Console.WriteLine("Item Movido.");
                    }
                }
                else
                {
                    item.Delete(DeleteMode.MoveToDeletedItems);//lo movemos a la papelera
                    Console.WriteLine("Item Movido a carpeta Eliminados");
                }
            }
            catch (Exception)
            {
            }
            return(respuesta);
        }
Esempio n. 29
0
        public questStatus Delete(FolderId folderId)
        {
            // Initialize
            questStatus status = null;


            // Perform delete.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = delete(dbContext, folderId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Esempio n. 30
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            int hash = 17;

            hash = hash * 23 + Id.GetHashCode();
            hash = hash * 23 + OrgId.GetHashCode();
            hash = hash * 23 + Title.GetHashCode();
            hash = hash * 23 + Uid.GetHashCode();
            hash = hash * 23 + Data.GetHashCode();

            if (FolderId.HasValue)
            {
                hash = hash * 23 + FolderId.GetHashCode();
            }

            return(hash);
        }
        /// <summary>
        /// Tries to read element from XML
        /// </summary>
        /// <param name="reader">XML reader</param>
        /// <returns>Whether reading succeeded</returns>
        internal override bool TryReadElementFromXml(EwsServiceXmlReader reader)
        {
            switch (reader.LocalName)
            {
                case XmlElementNames.Id:
                    this.Id = reader.ReadElementValue();
                    break;
                case XmlElementNames.SourceId:
                    this.SourceId = new ItemId();
                    this.SourceId.LoadFromXml(reader, reader.LocalName);
                    break;
                case XmlElementNames.DisplayName:
                    this.DisplayName = reader.ReadElementValue();
                    break;
                case XmlElementNames.IsWritable:
                    this.IsWritable = reader.ReadElementValue<bool>();
                    break;
                case XmlElementNames.IsQuickContact:
                    this.IsQuickContact = reader.ReadElementValue<bool>();
                    break;
                case XmlElementNames.IsHidden:
                    this.IsHidden = reader.ReadElementValue<bool>();
                    break;
                case XmlElementNames.FolderId:
                    this.FolderId = new FolderId();
                    this.FolderId.LoadFromXml(reader, reader.LocalName);
                    break;

                default:
                    return base.TryReadElementFromXml(reader);
            }

            return true;
        }
        /// <summary>
        /// Creates an instance with all values
        /// </summary>
        /// <param name="id">Attribution id</param>
        /// <param name="sourceId">Source Id</param>
        /// <param name="displayName">Display name</param>
        /// <param name="isWritable">Whether writable</param>
        /// <param name="isQuickContact">Wther quick contact</param>
        /// <param name="isHidden">Whether hidden</param>
        /// <param name="folderId">Folder id</param>
        public Attribution(string id, ItemId sourceId, string displayName, bool isWritable, bool isQuickContact, bool isHidden, FolderId folderId)
            : this()
        {
            EwsUtilities.ValidateParam(id, "id");
            EwsUtilities.ValidateParam(displayName, "displayName");

            this.Id = id;
            this.SourceId = sourceId;
            this.DisplayName = displayName;
            this.IsWritable = isWritable;
            this.IsQuickContact = isQuickContact;
            this.IsHidden = isHidden;
            this.FolderId = folderId;
        }