示例#1
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))
                {
                    var 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))
                {
                    var 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))
                {
                    var 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

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

                var 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);
            }
示例#2
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);

                var 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);

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

                var now = DateTime.Now;

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

                var 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);
            }
示例#3
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;

                string tempEmail;

                var addressType = GetMapiPropertyString(MapiTags.PR_ADDRTYPE);
                if (string.IsNullOrEmpty(addressType))
                    addressType = string.Empty;

                switch (addressType.ToUpperInvariant())
                {
                    case "EX":
                        // In the case of an "Exchange address type" we should try to read the
                        // PR_SMTP_ADDRESS tag first, otherwhise we have a change to get an E-mail address
                        // like /O=EXCHANGE/OU=First administrative group/cn=recipients/cn=cmma.van.spelde
                        tempEmail = GetMapiPropertyString(MapiTags.PR_SMTP_ADDRESS);

                        if (string.IsNullOrEmpty(tempEmail))
                            tempEmail = GetMapiPropertyString(MapiTags.PR_EMAIL_ADDRESS);
                        break;

                    default:
                        tempEmail = GetMapiPropertyString(MapiTags.PR_EMAIL_ADDRESS);

                        if (string.IsNullOrEmpty(tempEmail))
                            tempEmail = GetMapiPropertyString(MapiTags.PR_SMTP_ADDRESS);
                        break;
                }

                // If no E-mail address could be found then try to read the very rare PR_ORGEMAILADDR tag
                if (string.IsNullOrEmpty(tempEmail))
                    tempEmail = GetMapiPropertyString(MapiTags.PR_ORGEMAILADDR);

                tempEmail = EmailAddress.RemoveSingleQuotes(tempEmail);
                var tempDisplayName = EmailAddress.RemoveSingleQuotes(GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME));

                Email = tempEmail;
                DisplayName = tempDisplayName;

                // Sometimes the E-mail address and displayname get swapped so check if they are valid
                if (!EmailAddress.IsEmailAddressValid(tempEmail) && EmailAddress.IsEmailAddressValid(tempDisplayName))
                {
                    // Swap them
                    Email = tempDisplayName;
                    DisplayName = tempEmail;
                }
                else if (EmailAddress.IsEmailAddressValid(tempDisplayName))
                {
                    // If the displayname is an emailAddress them move it
                    Email = tempDisplayName;
                    DisplayName = tempDisplayName;
                }

                if (string.Equals(tempEmail, tempDisplayName, StringComparison.InvariantCultureIgnoreCase))
                    DisplayName = string.Empty;

                // 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.
                var displayType = GetMapiPropertyInt32(MapiTags.PR_DISPLAY_TYPE_EX);
                if (displayType != null && displayType == MapiTags.RecipientRoom)
                {
                    Type = RecipientType.Room;
                }
                else
                {
                    var 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;
                        }
                    }
                }
            }
示例#4
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;
 }
示例#5
0
        private GenResult EmailMessageFromMessage(
            StoredContact sender,
            StoredContact recipient,
            Storage.Message msg)
        {
            GenResult res = new GenResult();
            try
            {
                EmailAddress em =
                    Contact.Bind(this.service, new ItemId(sender.UniqId))
                        .EmailAddresses[EmailAddressKey.EmailAddress1];

                EmailMessage newMsg = new EmailMessage(this.service)
                {
                    From = em,
                    Sender = em,
                    Body = new MessageBody(msg.BodyHtml),
                    Subject = msg.Subject
                };

                newMsg.Save(WellKnownFolderName.Drafts);

                foreach (object obj in msg.Attachments)
                {
                    Storage.Attachment attach = obj as Storage.Attachment;
                    if (attach == null)
                        continue;
                    newMsg.Attachments.AddFileAttachment(attach.FileName, attach.Data);
                }

                this.FillAdresses(ref newMsg, recipient.Email);

                res.msg = newMsg;

                // делаем ли форвард
                if (RndTrueFalse())
                {
                    newMsg.Update(ConflictResolutionMode.AlwaysOverwrite);
                    ResponseMessage respMsg = newMsg.CreateForward();
                    respMsg.BodyPrefix = @"test body prefix for forward message";
                    this.FillAdressesForResponse(ref respMsg, this.RndRecipMail());
                    respMsg.Save(WellKnownFolderName.Drafts);
                    res.response = respMsg;
                }

                // делаем ли реплай
                if (RndTrueFalse())
                {
                    /*newMsg.ReplyTo.Add(_RndRecipMail());
                    if (_RndTrueFalse())
                    {
                        newMsg.ReplyTo.Add(_RndRecipMail());
                    }

                    if (_RndTrueFalse()) */
                    {
                        newMsg.Update(ConflictResolutionMode.AlwaysOverwrite);
                        ResponseMessage replMsg = newMsg.CreateReply(RndTrueFalse());
                        replMsg.BodyPrefix = @"test body prefix for reply message";
                        this.FillAdressesForResponse(ref replMsg, recipient.Email);
                        replMsg.Save(WellKnownFolderName.Drafts);
                        res.reply = replMsg;
                    }
                }
            }
            catch (Exception exc)
            {
                GenericLogger<Generator>.Error(
                    LocalizibleStrings.ErrorCreateFromTemplate + msg.FileName, exc);
            }
            return res;
        }
示例#6
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._rootStorage)
 {
     _propHeaderSize = MapiTags.PropertiesStreamHeaderTop;
 }
示例#7
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._rootStorage)
            {
                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))
                {
                    var 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))
                {
                    var 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))
                {
                    var 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

                var birthday = GetMapiPropertyDateTime(MapiTags.PR_BIRTHDAY);
                if (birthday != null)
                {
                    Birthday = ((DateTime)birthday).ToLocalTime();
                }

                var 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);
            }
示例#8
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
                var 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>();
                var 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
            }