Exemplo n.º 1
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="Storage.Sender" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            internal Sender(Storage message)
                : base(message._storage)
            {
                //GC.SuppressFinalize(message);
                _propHeaderSize = MapiTags.PropertiesStreamHeaderAttachOrRecip;

                Email = GetMapiPropertyString(MapiTags.PR_SENDER_EMAIL_ADDRESS);

                if (string.IsNullOrEmpty(Email) || Email.IndexOf('@') < 0)
                    Email = GetMapiPropertyString(MapiTags.PR_SENDER_EMAIL_ADDRESS_2);

                if (string.IsNullOrEmpty(Email) || Email.IndexOf("@", StringComparison.Ordinal) < 0)
                {
                    string addressType = GetMapiPropertyString(MapiTags.PR_SENDER_ADDRTYPE);
                    if (addressType == null || addressType == "EX")
                        Email = null;
                    else
                    {
                        // Get address from email headers. The headers are not present when the addressType = "EX"
                        string header = GetStreamAsString(MapiTags.HeaderStreamName, Encoding.Unicode);
                        if (header == null) return;
                        Match matches = Regex.Match(header, "From:.*<(?<email>.*?)>");
                        Email = matches.Groups["email"].ToString();
                    }
                }

                DisplayName = GetMapiPropertyString(MapiTags.PR_SENDER_NAME);
            }
Exemplo n.º 2
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="Storage.Recipient" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            internal Recipient(Storage message)
                : base(message._storage)
            {
                GC.SuppressFinalize(message);
                _propHeaderSize = MapiTags.PropertiesStreamHeaderAttachOrRecip;

                Email = GetMapiPropertyString(MapiTags.PR_EMAIL_1);

                if (string.IsNullOrEmpty(Email))
                    Email = GetMapiPropertyString(MapiTags.PR_EMAIL_2);

                DisplayName = GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME);

                // To reliably determine if a recipient is a conference room, use the Messaging API (MAPI) property, PidTagDisplayTypeEx,
                // of the Recipient object. You can access this property using the PropertyAccessor object in the Outlook object model.
                // The PidTagDisplayTypeEx property is represented as "http://schemas.microsoft.com/mapi/proptag/0x39050003" in the MAPI
                // proptag namespace. Note that the PidTagDisplayTypeEx property is not available in versions of Microsoft Exchange Server
                // earlier than Microsoft Exchange Server 2007; in such earlier versions of Exchange Server, you can use the Recipient.
                // Type property and assume that a recipient having a type other than olResource is not a conference room.
                int? displayType = GetMapiPropertyInt32(MapiTags.PR_DISPLAY_TYPE_EX);
                if (displayType != null && displayType == MapiTags.RecipientRoom)
                {
                    Type = RecipientType.Room;
                }
                else
                {
                    int? recipientType = GetMapiPropertyInt32(MapiTags.PR_RECIPIENT_TYPE);

                    if (recipientType == null)
                    {
                        Type = null;
                    }
                    else
                    {
                        switch (recipientType)
                        {
                            case MapiTags.RecipientTo:
                                Type = RecipientType.To;
                                break;

                            case MapiTags.RecipientCC:
                                Type = RecipientType.Cc;
                                break;

                            case MapiTags.RecipientBCC:
                                Type = RecipientType.Bcc;
                                break;

                            case MapiTags.RecipientResource:
                                Type = RecipientType.Resource;
                                break;

                            default:
                                Type = RecipientType.Unknown;
                                break;
                        }
                    }
                }
            }
Exemplo n.º 3
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="Storage.Flag" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            internal Flag(Storage message)
                : base(message._storage)
            {
                _namedProperties = message._namedProperties;
                _propHeaderSize = MapiTags.PropertiesStreamHeaderTop;

                Request = GetMapiPropertyString(MapiTags.FlagRequest);

                int? status = GetMapiPropertyInt32(MapiTags.PR_FLAG_STATUS);
                if (status == null)
                    Status = null;
                else
                    Status = (FlagStatus) status;
            }
Exemplo n.º 4
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="Storage.Contact" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            internal Contact(Storage message)
                : base(message._storage)
            {
                GC.SuppressFinalize(message);
                _namedProperties = message._namedProperties;
                _propHeaderSize = MapiTags.PropertiesStreamHeaderTop;

                DisplayName = GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME);
                Prefix = GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME_PREFIX);
                Initials = GetMapiPropertyString(MapiTags.PR_INITIALS);
                SurName = GetMapiPropertyString(MapiTags.PR_SURNAME);
                GivenName = GetMapiPropertyString(MapiTags.PR_GIVEN_NAME);
                Generation = GetMapiPropertyString(MapiTags.PR_GENERATION);
                Function = GetMapiPropertyString(MapiTags.PR_TITLE);
                Department = GetMapiPropertyString(MapiTags.PR_DEPARTMENT_NAME);
                Company = GetMapiPropertyString(MapiTags.PR_COMPANY_NAME);

                #region Business address information

                WorkAddress = GetMapiPropertyString(MapiTags.WorkAddress);
                BusinessAddressStreet = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_STREET);
                BusinessAddressCity = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_CITY);
                BusinessAddressState = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE);
                BusinessAddressPostalCode = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_POSTAL_CODE);
                BusinessAddressCountry = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_COUNTRY);
                BusinessTelephoneNumber = GetMapiPropertyString(MapiTags.PR_BUSINESS_TELEPHONE_NUMBER);
                BusinessTelephoneNumber2 = GetMapiPropertyString(MapiTags.PR_BUSINESS2_TELEPHONE_NUMBER);
                BusinessFaxNumber = GetMapiPropertyString(MapiTags.PR_BUSINESS_FAX_NUMBER);
                BusinessHomePage = GetMapiPropertyString(MapiTags.PR_BUSINESS_HOME_PAGE);

                // WorkAddress is only filled when the msg object is made with Outlook 2007 or higher.
                // So we fill it from code.
                if (string.IsNullOrEmpty(WorkAddress))
                {
                    string workAddress = string.Empty;

                    if (!string.IsNullOrEmpty(BusinessAddressStreet))
                        workAddress += BusinessAddressStreet + Environment.NewLine;

                    if (!string.IsNullOrEmpty(BusinessAddressPostalCode))
                        workAddress += BusinessAddressPostalCode + Environment.NewLine;

                    if (!string.IsNullOrEmpty(BusinessAddressCity))
                        workAddress += BusinessAddressCity + Environment.NewLine;

                    if (!string.IsNullOrEmpty(BusinessAddressCountry))
                        workAddress += BusinessAddressCountry + Environment.NewLine;

                    if (!string.IsNullOrEmpty(workAddress))
                        WorkAddress = workAddress;
                }

                #endregion

                #region Home address information

                HomeAddress = GetMapiPropertyString(MapiTags.HomeAddress);
                HomeAddressStreet = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_STREET);
                HomeAddressCity = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_CITY);
                HomeAddressState = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_STATE_OR_PROVINCE);
                HomeAddressPostalCode = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_POSTAL_CODE);
                HomeAddressCountry = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_COUNTRY);
                HomeTelephoneNumber = GetMapiPropertyString(MapiTags.PR_HOME_TELEPHONE_NUMBER);
                HomeTelephoneNumber2 = GetMapiPropertyString(MapiTags.PR_HOME2_TELEPHONE_NUMBER);
                HomeFaxNumber = GetMapiPropertyString(MapiTags.PR_HOME_FAX_NUMBER);

                // HomeAddress is only filled when the msg object is made with Outlook 2007 or higher.
                // So we fill it from code.
                if (string.IsNullOrEmpty(HomeAddress))
                {
                    string homeAddress = string.Empty;

                    if (!string.IsNullOrEmpty(HomeAddressStreet))
                        homeAddress += HomeAddressStreet + Environment.NewLine;

                    if (!string.IsNullOrEmpty(HomeAddressPostalCode))
                        homeAddress += HomeAddressPostalCode + Environment.NewLine;

                    if (!string.IsNullOrEmpty(HomeAddressCity))
                        homeAddress += HomeAddressCity + Environment.NewLine;

                    if (!string.IsNullOrEmpty(HomeAddressCountry))
                        homeAddress += HomeAddressCountry + Environment.NewLine;

                    if (!string.IsNullOrEmpty(homeAddress))
                        HomeAddress = homeAddress;
                }

                #endregion

                #region Other address information

                OtherAddress = GetMapiPropertyString(MapiTags.OtherAddress);
                OtherAddressStreet = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_STREET);
                OtherAddressCity = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_CITY);
                OtherAddressState = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_STATE_OR_PROVINCE);
                OtherAddressPostalCode = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_POSTAL_CODE);
                OtherAddressCountry = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_COUNTRY);
                OtherTelephoneNumber = GetMapiPropertyString(MapiTags.PR_OTHER_TELEPHONE_NUMBER);

                // OtherAddress is only filled when the msg object is made with Outlook 2007 or higher.
                // So we fill it from code.
                if (string.IsNullOrEmpty(OtherAddress))
                {
                    string otherAddress = string.Empty;

                    if (!string.IsNullOrEmpty(OtherAddressStreet))
                        otherAddress += OtherAddressStreet + Environment.NewLine;

                    if (!string.IsNullOrEmpty(OtherAddressPostalCode))
                        otherAddress += OtherAddressPostalCode + Environment.NewLine;

                    if (!string.IsNullOrEmpty(OtherAddressCity))
                        otherAddress += OtherAddressCity + Environment.NewLine;

                    if (!string.IsNullOrEmpty(OtherAddressCountry))
                        otherAddress += OtherAddressCountry + Environment.NewLine;

                    if (!string.IsNullOrEmpty(otherAddress))
                        OtherAddress = otherAddress;
                }

                #endregion

                #region Primary information

                PrimaryTelephoneNumber = GetMapiPropertyString(MapiTags.PR_PRIMARY_TELEPHONE_NUMBER);
                PrimaryFaxNumber = GetMapiPropertyString(MapiTags.PR_PRIMARY_FAX_NUMBER);

                #endregion

                #region Assistant information

                AssistantName = GetMapiPropertyString(MapiTags.PR_ASSISTANT);
                AssistantTelephoneNumber = GetMapiPropertyString(MapiTags.PR_ASSISTANT_TELEPHONE_NUMBER);

                #endregion

                InstantMessagingAddress = GetMapiPropertyString(MapiTags.InstantMessagingAddress);

                #region Telephone numbers

                CompanyMainTelephoneNumber = GetMapiPropertyString(MapiTags.PR_COMPANY_MAIN_PHONE_NUMBER);
                CellularTelephoneNumber = GetMapiPropertyString(MapiTags.PR_CELLULAR_TELEPHONE_NUMBER);
                CarTelephoneNumber = GetMapiPropertyString(MapiTags.PR_CAR_TELEPHONE_NUMBER);
                RadioTelephoneNumber = GetMapiPropertyString(MapiTags.PR_RADIO_TELEPHONE_NUMBER);
                BeeperTelephoneNumber = GetMapiPropertyString(MapiTags.PR_BEEPER_TELEPHONE_NUMBER);
                CallbackTelephoneNumber = GetMapiPropertyString(MapiTags.PR_CALLBACK_TELEPHONE_NUMBER);
                TextTelephone = GetMapiPropertyString(MapiTags.PR_TELEX_NUMBER);
                ISDNNumber = GetMapiPropertyString(MapiTags.PR_ISDN_NUMBER);
                TelexNumber = GetMapiPropertyString(MapiTags.PR_TELEX_NUMBER);

                #endregion

                #region E-mail information

                Email1EmailAddress = GetMapiPropertyString(MapiTags.Email1EmailAddress);
                Email1DisplayName = GetMapiPropertyString(MapiTags.Email1DisplayName);
                Email2EmailAddress = GetMapiPropertyString(MapiTags.Email2EmailAddress);
                Email2DisplayName = GetMapiPropertyString(MapiTags.Email2DisplayName);
                Email3EmailAddress = GetMapiPropertyString(MapiTags.Email3EmailAddress);
                Email3DisplayName = GetMapiPropertyString(MapiTags.Email3DisplayName);

                #endregion

                DateTime? birthday = GetMapiPropertyDateTime(MapiTags.PR_BIRTHDAY);
                if (birthday != null)
                    Birthday = ((DateTime) birthday).ToLocalTime();

                DateTime? weddingAnniversary = GetMapiPropertyDateTime(MapiTags.PR_WEDDING_ANNIVERSARY);
                if (weddingAnniversary != null)
                    WeddingAnniversary = ((DateTime) weddingAnniversary).ToLocalTime();

                SpouseName = GetMapiPropertyString(MapiTags.PR_SPOUSE_NAME);
                Profession = GetMapiPropertyString(MapiTags.PR_PROFESSION);
                Html = GetMapiPropertyString(MapiTags.Html);
            }
Exemplo n.º 5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Storage.MapiTagMapper" /> class.
 /// </summary>
 /// <param name="message"> The message. </param>
 internal MapiTagMapper(Storage message)
     : base(message._storage)
 {
     GC.SuppressFinalize(message);
     _propHeaderSize = MapiTags.PropertiesStreamHeaderTop;
 }
Exemplo n.º 6
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="Storage.Task" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            internal Task(Storage message)
                : base(message._storage)
            {
                //GC.SuppressFinalize(message);
                _namedProperties = message._namedProperties;
                _propHeaderSize = MapiTags.PropertiesStreamHeaderTop;

                StartDate = GetMapiPropertyDateTime(MapiTags.TaskStartDate);
                DueDate = GetMapiPropertyDateTime(MapiTags.TaskDueDate);

                int? status = GetMapiPropertyInt32(MapiTags.TaskStatus);
                if (status == null)
                    Status = null;
                else
                    Status = (TaskStatus) status;

                switch (Status)
                {
                    case TaskStatus.NotStarted:
                        StatusText = LanguageConsts.TaskStatusNotStartedText;
                        break;

                    case TaskStatus.InProgess:
                        StatusText = LanguageConsts.TaskStatusInProgressText;
                        break;

                    case TaskStatus.Waiting:
                        StatusText = LanguageConsts.TaskStatusWaitingText;
                        break;

                    case TaskStatus.Complete:
                        StatusText = LanguageConsts.TaskStatusCompleteText;
                        break;

                    default:
                        StatusText = null;
                        break;
                }

                PercentageComplete = GetMapiPropertyDouble(MapiTags.PercentComplete);
                Complete = GetMapiPropertyBool(MapiTags.TaskComplete);

                int? estimatedEffort = GetMapiPropertyInt32(MapiTags.TaskEstimatedEffort);
                if (estimatedEffort == null)
                    EstimatedEffort = null;
                else
                    EstimatedEffort = new TimeSpan(0, 0, (int) estimatedEffort);

                DateTime now = DateTime.Now;

                EstimatedEffortText = (EstimatedEffort == null
                    ? null
                    : DateDifference.Difference(now, now + ((TimeSpan) EstimatedEffort)).ToString());

                int? actualEffort = GetMapiPropertyInt32(MapiTags.TaskActualEffort);
                if (actualEffort == null)
                    ActualEffort = null;
                else
                    ActualEffort = new TimeSpan(0, 0, (int) actualEffort);

                ActualEffortText = (ActualEffort == null
                    ? null
                    : DateDifference.Difference(now, now + ((TimeSpan) ActualEffort)).ToString());

                Owner = GetMapiPropertyString(MapiTags.Owner);
                Contacts = GetMapiPropertyStringList(MapiTags.Contacts);
                Companies = GetMapiPropertyStringList(MapiTags.Companies);
                BillingInformation = GetMapiPropertyString(MapiTags.Billing);
                Mileage = GetMapiPropertyString(MapiTags.Mileage);
                CompleteTime = GetMapiPropertyDateTime(MapiTags.PR_FLAG_COMPLETE_TIME);
            }
Exemplo n.º 7
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="Storage.Task" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            internal Appointment(Storage message)
                : base(message._storage)
            {
                //GC.SuppressFinalize(message);
                _namedProperties = message._namedProperties;
                _propHeaderSize = MapiTags.PropertiesStreamHeaderTop;

                Location = GetMapiPropertyString(MapiTags.Location);
                Start = GetMapiPropertyDateTime(MapiTags.AppointmentStartWhole);
                End = GetMapiPropertyDateTime(MapiTags.AppointmentEndWhole);
                AllAttendees = GetMapiPropertyString(MapiTags.AppointmentAllAttendees);
                ToAttendees = GetMapiPropertyString(MapiTags.AppointmentToAttendees);
                CclAttendees = GetMapiPropertyString(MapiTags.AppointmentCCAttendees);

                #region Recurrence

                int? recurrenceType = GetMapiPropertyInt32(MapiTags.ReccurrenceType);
                if (recurrenceType == null)
                {
                    ReccurrenceType = AppointmentRecurrenceType.None;
                    RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeNoneText;
                }
                else
                {
                    switch (recurrenceType)
                    {
                        case 1:
                            ReccurrenceType = AppointmentRecurrenceType.Daily;
                            break;

                        case 2:
                            ReccurrenceType = AppointmentRecurrenceType.Weekly;
                            break;

                        case 3:
                        case 4:
                            ReccurrenceType = AppointmentRecurrenceType.Montly;
                            break;

                        case 5:
                        case 6:
                            ReccurrenceType = AppointmentRecurrenceType.Yearly;
                            break;

                        default:
                            ReccurrenceType = AppointmentRecurrenceType.None;
                            break;
                    }

                    switch (ReccurrenceType)
                    {
                        case AppointmentRecurrenceType.Daily:
                            RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeDailyText;
                            break;

                        case AppointmentRecurrenceType.Weekly:
                            RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeWeeklyText;
                            break;

                        case AppointmentRecurrenceType.Montly:
                            RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeMonthlyText;
                            break;

                        case AppointmentRecurrenceType.Yearly:
                            RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeYearlyText;
                            break;
                    }
                }

                RecurrencePatern = GetMapiPropertyString(MapiTags.ReccurrencePattern);

                #endregion

                #region ClientIntent

                var clientIntentList = new List<AppointmentClientIntent>();
                int? clientIntent = GetMapiPropertyInt32(MapiTags.PidLidClientIntent);

                if (clientIntent == null)
                    ClientIntent = null;
                else
                {
                    var bitwiseValue = (int) clientIntent;

                    if ((bitwiseValue & 1) == 1)
                    {
                        clientIntentList.Add(AppointmentClientIntent.Manager);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentManagerText;
                    }

                    if ((bitwiseValue & 2) == 2)
                    {
                        clientIntentList.Add(AppointmentClientIntent.Delegate);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentDelegateText;
                    }

                    if ((bitwiseValue & 4) == 4)
                    {
                        clientIntentList.Add(AppointmentClientIntent.DeletedWithNoResponse);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentDeletedWithNoResponseText;
                    }

                    if ((bitwiseValue & 8) == 8)
                    {
                        clientIntentList.Add(AppointmentClientIntent.DeletedExceptionWithNoResponse);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentDeletedExceptionWithNoResponseText;
                    }

                    if ((bitwiseValue & 16) == 16)
                    {
                        clientIntentList.Add(AppointmentClientIntent.RespondedTentative);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentRespondedTentativeText;
                    }

                    if ((bitwiseValue & 32) == 32)
                    {
                        clientIntentList.Add(AppointmentClientIntent.RespondedAccept);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentRespondedAcceptText;
                    }

                    if ((bitwiseValue & 64) == 64)
                    {
                        clientIntentList.Add(AppointmentClientIntent.RespondedDecline);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentRespondedDeclineText;
                    }
                    if ((bitwiseValue & 128) == 128)
                    {
                        clientIntentList.Add(AppointmentClientIntent.ModifiedStartTime);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentModifiedStartTimeText;
                    }

                    if ((bitwiseValue & 256) == 256)
                    {
                        clientIntentList.Add(AppointmentClientIntent.ModifiedEndTime);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentModifiedEndTimeText;
                    }

                    if ((bitwiseValue & 512) == 512)
                    {
                        clientIntentList.Add(AppointmentClientIntent.ModifiedLocation);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentModifiedLocationText;
                    }

                    if ((bitwiseValue & 1024) == 1024)
                    {
                        clientIntentList.Add(AppointmentClientIntent.RespondedExceptionDecline);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentRespondedExceptionDeclineText;
                    }

                    if ((bitwiseValue & 2048) == 2048)
                    {
                        clientIntentList.Add(AppointmentClientIntent.Canceled);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentCanceledText;
                    }

                    if ((bitwiseValue & 4096) == 4096)
                    {
                        clientIntentList.Add(AppointmentClientIntent.ExceptionCanceled);
                        ClientIntentText = LanguageConsts.AppointmentClientIntentExceptionCanceledText;
                    }

                    ClientIntent = clientIntentList.AsReadOnly();
                }

                #endregion
            }