Quantcast
Channel: Exchange Server Development forum
Viewing all 7132 articles
Browse latest View live

Shared Exchange / Office 365 Coexistance

$
0
0

Hi,

I've got a single domain used by a shared OVH Exchange and a Office 365 tenant.

I want to migrate some of those users to Office 365 but i wonder how i can keep them both receiving their emails.

Are the on-prem users still gonna be able to send emails IF i change the MX to Office 365 and create a connector to redirect emails to the OVH Exchange if the mailbox doesn't exist ?

The goal is to use Office 365 only for users that i want but the on-prem users need to keep receiving/sending emails.

Best regards,

B.B


Office 365 Exchange Online Hybrid With Exchange Server 2013 with DAG

$
0
0

Hi Everyone,

I would like just to ask if there will be a problem in my Database Availability Group when I configured a hybrid setup of Exchange Server 2013 and Office 365

Thanks,

Lawrence


Lawrence

How to achieve single sign on using EWS java API

$
0
0

Hi,

I have to make use of EWS java API for single sign on environment. I have to created the connection with exchange server successfully but have to use same with SSO environment. 

Any help will be appreciated

How to achieve single sign on using EWS java API

$
0
0

we use spring mvc,

need to fetch user mails from mexchange server and to pass windows credentials or default credentials. 

.MSG File Metadata Extraction - Sender SMTP Email

$
0
0

Our organization is currently in the process of extracting a processing old .MSG files that have been stored by current and possibly former employees. As part of this process we are trying to extract the Sender SMTP email address from these old emails. However since most of these were/are internal users, the msg file has the Sender Address stored as an exchange address. We have tried the following to with no luck:

MsgReader.Outlook.Storage.Message

var senderAddress = string.Empty;
using (var msg = new Storage.Message(emailFilePath))
{
    senderAddress = msg.Sender.Email;
}

Microsoft.Office.Interop.Outlook.MailItem

var senderEmailAddress = this.SafeExtractEmailAddress(mail.Sender, mail.SenderEmailAddress);


private string SafeExtractEmailAddress(AddressEntry addressEntry, string currentEmail)
{
    var userEmailAddress = string.Empty;

    if (addressEntry != null &&
        (addressEntry.AddressEntryUserType == OlAddressEntryUserType.olExchangeUserAddressEntry
            || addressEntry.AddressEntryUserType == OlAddressEntryUserType.olExchangeRemoteUserAddressEntry))
    {
        userEmailAddress = addressEntry.GetExchangeUser()?.PrimarySmtpAddress;
    }

    if (string.IsNullOrWhiteSpace(userEmailAddress))
    {
        var recipient = this.outlookApplication.Session.CreateRecipient(currentEmail);
        var exchangeUser = recipient?.AddressEntry.GetExchangeUser();

        userEmailAddress = exchangeUser?.PrimarySmtpAddress ?? currentEmail;

        recipient.SafeRelease();
        exchangeUser.SafeRelease();
    }

    return userEmailAddress.ToLowerInvariant();
}


Aspose.Email.Mapi.MapiMessage

public string ExtractSender(MapiMessage msg)
{
    if (msg == null)
    {
        throw new ArgumentNullException(nameof(msg));
    }
    var senderEmailAddress = msg.SenderEmailAddress;
    ExchangeService exchangeService = this.exchangeServiceFactory.BuildService();

    // Create the ResolveNamesType and set the unresolved entry.

    if (msg.SenderAddressType == "EX")
    { 
        var resolutionCollection = exchangeService.ResolveName(msg.SenderEmailAddress, ResolveNameSearchLocation.ContactsThenDirectory, true);
        var nameResolutions = resolutionCollection.ToList();
        if (nameResolutions.Count > 0)
        {
            var nameResolution = nameResolutions.ElementAt(0);
            senderEmailAddress = nameResolution.Mailbox.Address;
        }
    }

    return senderEmailAddress;
}

Please assist with any other option we can look at to extract this.

Thanks,

Ivhani


Change Categories via powershell (Not working)

$
0
0
Hi

I made this script to put some emails into Categories. Where it looks at the Email, and the messageID.

But iam getting a error


using this plugin: https://www.powershellgallery.com/packages/Exch-Rest/3.6


Script: 

$messages = Import-Csv -Path c:\temp\123.csv

Connect-EXRMailbox -Mailbox "DOP@test.com"
ForEach ($message in $messages){
$MessageId = $message.messageID
$MailboxName = $message.Email
    $Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId 
     Set-EXRItemCategory -MailboxName $MailboxName -Item $Item -Categories @("red")

}
CSV:
"messageID","Email""HE1P192MB00423281AEEA3C8F5EC4CC20D1D80@HE1P192MB0042.EURP192.PROD.OUTLOOK.COM;testmail@test.com"

Error:
Version             : 1.1
Content             : System.Net.Http.StreamContent
StatusCode          : BadRequest
ReasonPhrase        : Bad Request
Headers             : {[Transfer-Encoding, System.String[]], [request-id, System.String[]], [client-request-id, System.String[]], [x-ms-ags-diagnostic, System.String[]]...}
RequestMessage      : Method: PATCH, RequestUri: 'https://graph.microsoft.com/v1.0/users('DOP@
test.com.
')/messages('')', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
                      {
                        Accept: application/json
                        X-AnchorMailbox: DOP@test.com
                        User-Agent: RestClient/1.1
                        Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IkFRQUJBQUFBQUFDNXVuYTBFVUZnVElGOEVsYXh0V2pURXhKVDVVbHZaS0V2aWxpQjZsTFhUTFBTSVFlWmRuVkVpZ01TbThZZzlxRWt3OHhNS2c5V1lsM
                      2o5VlpSZldtNkwwMUNnaGxZSUJETkhycEhSXzhCTVNBQSIsImFsZyI6IlJTMjU2IiwieDV0Ijoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIiwia2lkIjoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIn0.eyJhdW
                      QiOiJodHRwczovL0dyYXBoLk1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9iMTg3NWNkOC1hMzliLTQxYzctYTRhOC02MDFmNDNjNWEyMTIvIiwiaWF0IjoxNTQyNjM1NzE4LCJuYmYiOjE
                      1NDI2MzU3MTgsImV4cCI6MTU0MjYzOTYxOCwiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFWUUFxLzhKQUFBQUMvVU94ekJrOGVqSTQrKzY1QldabTZWVmhGNnN1emNqUXlLUDZSazgyc2UrNDBnL2ROeHcrY1lnK2k2V2py
                      TkdoSUNOK1dzWUdwUE85NTIzemJsaWNST3Y2SVhhMU9veTVLQUlOUkphb3UwPSIsImFtciI6WyJwd2QiLCJyc2EiLCJtZmEiXSwiYXBwX2Rpc3BsYXluYW1lIjoiRXhjaC1SRVNUIFBvd2Vyc2hlbGwgTW9kdWxlIFJlZ2lzd
                      HJhdGlvbiBGdWxsIEFjY2VzcyIsImFwcGlkIjoiNTQ3MTAzMGQtZjMxMS00YzVkLTkxZWYtNzRjYTg4NTQ2M2E3IiwiYXBwaWRhY3IiOiIwIiwiZGV2aWNlaWQiOiI4YjBkMWNkMy0xNDBmLTQ3NjMtOGZiZi1jODE5OGVjND
                      g3ZTYiLCJmYW1pbHlfbmFtZSI6Ik9wcGVubMOmbmRlciIsImdpdmVuX25hbWUiOiJEYW5pZWwiLCJpcGFkZHIiOiIyMTIuMTAuMTcyLjIzMSIsIm5hbWUiOiJEYW5pZWwgT3BwZW5sw6ZuZGVyIFtBdmlhbl0iLCJvaWQiOiI
                      0NmRhZGFlYy01M2Y2LTQyODMtYTM5MC0xOGU5YWZlZDE5YTEiLCJwbGF0ZiI6IjMiLCJwdWlkIjoiMTAwM0JGRkRBNTJFNTZENCIsInNjcCI6IkFjY2Vzc1Jldmlldy5SZWFkLkFsbCBBY2Nlc3NSZXZpZXcuUmVhZFdyaXRl
                      LkFsbCBBZ3JlZW1lbnQuUmVhZC5BbGwgQWdyZWVtZW50LlJlYWRXcml0ZS5BbGwgQWdyZWVtZW50QWNjZXB0YW5jZS5SZWFkIEFncmVlbWVudEFjY2VwdGFuY2UuUmVhZC5BbGwgQWxsU2l0ZXMuUmVhZCBBcHBDYXRhbG9nL
                      lJlYWRXcml0ZS5BbGwgQXVkaXRMb2cuUmVhZC5BbGwgQm9va2luZ3MuTWFuYWdlLkFsbCBCb29raW5ncy5SZWFkLkFsbCBCb29raW5ncy5SZWFkV3JpdGUuQWxsIEJvb2tpbmdzQXBwb2ludG1lbnQuUmVhZFdyaXRlLkFsbC
                      BDYWxlbmRhcnMuUmVhZCBDYWxlbmRhcnMuUmVhZC5BbGwgQ2FsZW5kYXJzLlJlYWQuU2hhcmVkIENhbGVuZGFycy5SZWFkV3JpdGUgQ2FsZW5kYXJzLlJlYWRXcml0ZS5BbGwgQ2FsZW5kYXJzLlJlYWRXcml0ZS5TaGFyZWQ
                      gQ29udGFjdHMuUmVhZCBDb250YWN0cy5SZWFkLkFsbCBDb250YWN0cy5SZWFkLlNoYXJlZCBDb250YWN0cy5SZWFkV3JpdGUgQ29udGFjdHMuUmVhZFdyaXRlLkFsbCBDb250YWN0cy5SZWFkV3JpdGUuU2hhcmVkIERldmlj
                      ZS5Db21tYW5kIERldmljZS5SZWFkIERldmljZU1hbmFnZW1lbnRBcHBzLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRBcHBzLlJlYWRXcml0ZS5BbGwgRGV2aWNlTWFuYWdlbWVudENvbmZpZ3VyYXRpb24uUmVhZC5BbGwgR
                      GV2aWNlTWFuYWdlbWVudENvbmZpZ3VyYXRpb24uUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50TWFuYWdlZERldmljZXMuUHJpdmlsZWdlZE9wZXJhdGlvbnMuQWxsIERldmljZU1hbmFnZW1lbnRNYW5hZ2VkRGV2aW
                      Nlcy5SZWFkLkFsbCBEZXZpY2VNYW5hZ2VtZW50TWFuYWdlZERldmljZXMuUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkLkFsbCBEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkV3JpdGUuQWxsIERldml
                      jZU1hbmFnZW1lbnRTZXJ2aWNlQ29uZmlnLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRTZXJ2aWNlQ29uZmlnLlJlYWRXcml0ZS5BbGwgRGlyZWN0b3J5LkFjY2Vzc0FzVXNlci5BbGwgRGlyZWN0b3J5LlJlYWQuQWxsIERp
                      cmVjdG9yeS5SZWFkV3JpdGUuQWxsIEVBUy5BY2Nlc3NBc1VzZXIuQWxsIEVkdUFkbWluaXN0cmF0aW9uLlJlYWQgRWR1QWRtaW5pc3RyYXRpb24uUmVhZFdyaXRlIEVkdUFzc2lnbm1lbnRzLlJlYWQgRWR1QXNzaWdubWVud
                      HMuUmVhZEJhc2ljIEVkdUFzc2lnbm1lbnRzLlJlYWRXcml0ZSBFZHVBc3NpZ25tZW50cy5SZWFkV3JpdGVCYXNpYyBFZHVSb3N0ZXIuUmVhZCBFZHVSb3N0ZXIuUmVhZEJhc2ljIEVkdVJvc3Rlci5SZWFkV3JpdGUgZW1haW
                      wgRXhjaGFuZ2UuTWFuYWdlIEZpbGVzLlJlYWQgRmlsZXMuUmVhZC5BbGwgRmlsZXMuUmVhZC5TZWxlY3RlZCBGaWxlcy5SZWFkV3JpdGUgRmlsZXMuUmVhZFdyaXRlLkFsbCBGaWxlcy5SZWFkV3JpdGUuQXBwRm9sZGVyIEZ
                      pbGVzLlJlYWRXcml0ZS5TZWxlY3RlZCBGaW5hbmNpYWxzLlJlYWRXcml0ZS5BbGwgZnVsbF9hY2Nlc3NfYXNfdXNlciBHcm91cC5SZWFkLkFsbCBHcm91cC5SZWFkV3JpdGUuQWxsIElkZW50aXR5UHJvdmlkZXIuUmVhZC5B
                      bGwgSWRlbnRpdHlQcm92aWRlci5SZWFkV3JpdGUuQWxsIElkZW50aXR5Umlza0V2ZW50LlJlYWQuQWxsIGlkZW50aXR5cmlza3l1c2VyLnJlYWQuYWxsIE1haWwuUmVhZCBNYWlsLlJlYWQuQWxsIE1haWwuUmVhZC5TaGFyZ
                      WQgTWFpbC5SZWFkV3JpdGUgTWFpbC5SZWFkV3JpdGUuQWxsIE1haWwuUmVhZFdyaXRlLlNoYXJlZCBNYWlsLlNlbmQgTWFpbC5TZW5kLkFsbCBNYWlsLlNlbmQuU2hhcmVkIE1haWxib3hTZXR0aW5ncy5SZWFkIE1haWxib3
                      hTZXR0aW5ncy5SZWFkV3JpdGUgTWVtYmVyLlJlYWQuSGlkZGVuIE5vdGVzLkNyZWF0ZSBOb3Rlcy5SZWFkIE5vdGVzLlJlYWQuQWxsIE5vdGVzLlJlYWRXcml0ZSBOb3Rlcy5SZWFkV3JpdGUuQWxsIE5vdGVzLlJlYWRXcml
                      0ZS5DcmVhdGVkQnlBcHAgTm90aWZpY2F0aW9ucy5SZWFkV3JpdGUuQ3JlYXRlZEJ5QXBwIG9mZmxpbmVfYWNjZXNzIG9wZW5pZCBQZW9wbGUuUmVhZCBQZW9wbGUuUmVhZC5BbGwgUGVvcGxlLlJlYWRXcml0ZSBQb2xpY3ku
                      UmVhZC5BbGwgUG9saWN5LlJlYWRXcml0ZS5Db25kaXRpb25hbEFjY2VzcyBQcml2aWxlZ2VkQWNjZXNzLlJlYWRXcml0ZS5BenVyZUFEIFByaXZpbGVnZWRBY2Nlc3MuUmVhZFdyaXRlLkF6dXJlUmVzb3VyY2VzIHByb2Zpb
                      GUgUHJvZ3JhbUNvbnRyb2wuUmVhZC5BbGwgUHJvZ3JhbUNvbnRyb2wuUmVhZFdyaXRlLkFsbCBSZXBvcnRzLlJlYWQuQWxsIFNlY3VyaXR5RXZlbnRzLlJlYWQuQWxsIFNlY3VyaXR5RXZlbnRzLlJlYWRXcml0ZS5BbGwgU2
                      l0ZXMuRnVsbENvbnRyb2wuQWxsIFNpdGVzLk1hbmFnZS5BbGwgU2l0ZXMuUmVhZC5BbGwgU2l0ZXMuUmVhZFdyaXRlLkFsbCBTdWJzY3JpcHRpb24uUmVhZC5BbGwgVGFza3MuUmVhZCBUYXNrcy5SZWFkLlNoYXJlZCBUYXN
                      rcy5SZWFkV3JpdGUgVGFza3MuUmVhZFdyaXRlLlNoYXJlZCBVc2VyLkV4cG9ydC5BbGwgVXNlci5JbnZpdGUuQWxsIFVzZXIuUmVhZCBVc2VyLlJlYWQuQWxsIFVzZXIuUmVhZEJhc2ljLkFsbCBVc2VyLlJlYWRXcml0ZSBV
                      c2VyLlJlYWRXcml0ZS5BbGwgVXNlckFjdGl2aXR5LlJlYWRXcml0ZS5DcmVhdGVkQnlBcHAgVXNlclRpbWVsaW5lQWN0aXZpdHkuV3JpdGUuQ3JlYXRlZEJ5QXBwIiwic2lnbmluX3N0YXRlIjpbImttc2kiXSwic3ViIjoiN
                      zNyZzI3OEFBVG1uU0ZNS05XMUhJYTduZXduNG5UWUdsYVo1S3Y2cVlxUSIsInRpZCI6ImIxODc1Y2Q4LWEzOWItNDFjNy1hNGE4LTYwMWY0M2M1YTIxMiIsInVuaXF1ZV9uYW1lIjoiZG9wQGF2aWFuLmRrIiwidXBuIjoiZG
                      9wQGF2aWFuLmRrIiwidXRpIjoiUWU0elFodGdkVVdMVVV6UHpvZExBQSIsInZlciI6IjEuMCIsIndpZHMiOlsiNjJlOTAzOTQtNjlmNS00MjM3LTkxOTAtMDEyMTc3MTQ1ZTEwIl0sInhtc190Y2R0IjoxNTA3MTg5ODcyfQ.
                      IvwD1ow-aHTE_OIyiCk7QFmRUAbPY6WaFBdyXouiG7fu8WJxmtgIp2D2yzyzA3P5fAs34PPH7tNcsyOJBWQlUSbTXjML_T5X_Y8xiC0sJlXK5RpQ1ftCicLyo4MuCp7Z5Yx7V7Q3yLZ5hIYuAMBa_jbAzBqM9tOnqR8pa56fx
                      DLanqqikJVJ5cpEemZRc4QyY2B9shbIpxlu9r5kokkbzkDguaPT-jrPtLivlKr8MuCZ11ToDHTdjqj78S6mjR7PoWV649knPoBoVUzSdvUzxHi6XskwyYheQtmQQsF6Q0T_1lntsbbPoogDaFi-xH83KwVn7INhpGUkl0GQUw
                      -BMw
                        Content-Type: application/json; charset=utf-8
                        Content-Length: 26
                      }
IsSuccessStatusCode : False

Result                 : {
                           "error": {"code": "ErrorInvalidIdEmpty","message": "Id must be non-empty.","innerError": {"request-id": "b9b322d4-d731-4ae5-9adf-53662f9c6a39","date": "2018-11-19T14:00:19"
                             }
                           }
                         }
Id                     : 27919
Exception              : 
Status                 : RanToCompletion
IsCanceled             : False
IsCompleted            : True
CreationOptions        : None
AsyncState             : 
IsFaulted              : False
AsyncWaitHandle        : System.Threading.ManualResetEvent
CompletedSynchronously : False

Error making REST Patch BadRequest : Bad Request
Version             : 1.1
Content             : System.Net.Http.StreamContent
StatusCode          : BadRequest
ReasonPhrase        : Bad Request
Headers             : {[Transfer-Encoding, System.String[]], [request-id, System.String[]], [client-request-id, System.String[]], [x-ms-ags-diagnostic, System.String[]]...}
RequestMessage      : Method: PATCH, RequestUri: 'https://graph.microsoft.com/v1.0/users('DOP@
test.com.
')/messages('')', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
                      {
                        Accept: application/json
                        X-AnchorMailbox: DOP@
test.com.
                        User-Agent: RestClient/1.1
                        Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IkFRQUJBQUFBQUFDNXVuYTBFVUZnVElGOEVsYXh0V2pURXhKVDVVbHZaS0V2aWxpQjZsTFhUTFBTSVFlWmRuVkVpZ01TbThZZzlxRWt3OHhNS2c5V1lsM
                      2o5VlpSZldtNkwwMUNnaGxZSUJETkhycEhSXzhCTVNBQSIsImFsZyI6IlJTMjU2IiwieDV0Ijoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIiwia2lkIjoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIn0.eyJhdW
                      QiOiJodHRwczovL0dyYXBoLk1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9iMTg3NWNkOC1hMzliLTQxYzctYTRhOC02MDFmNDNjNWEyMTIvIiwiaWF0IjoxNTQyNjM1NzE4LCJuYmYiOjE
                      1NDI2MzU3MTgsImV4cCI6MTU0MjYzOTYxOCwiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFWUUFxLzhKQUFBQUMvVU94ekJrOGVqSTQrKzY1QldabTZWVmhGNnN1emNqUXlLUDZSazgyc2UrNDBnL2ROeHcrY1lnK2k2V2py
                      TkdoSUNOK1dzWUdwUE85NTIzemJsaWNST3Y2SVhhMU9veTVLQUlOUkphb3UwPSIsImFtciI6WyJwd2QiLCJyc2EiLCJtZmEiXSwiYXBwX2Rpc3BsYXluYW1lIjoiRXhjaC1SRVNUIFBvd2Vyc2hlbGwgTW9kdWxlIFJlZ2lzd
                      HJhdGlvbiBGdWxsIEFjY2VzcyIsImFwcGlkIjoiNTQ3MTAzMGQtZjMxMS00YzVkLTkxZWYtNzRjYTg4NTQ2M2E3IiwiYXBwaWRhY3IiOiIwIiwiZGV2aWNlaWQiOiI4YjBkMWNkMy0xNDBmLTQ3NjMtOGZiZi1jODE5OGVjND
                      g3ZTYiLCJmYW1pbHlfbmFtZSI6Ik9wcGVubMOmbmRlciIsImdpdmVuX25hbWUiOiJEYW5pZWwiLCJpcGFkZHIiOiIyMTIuMTAuMTcyLjIzMSIsIm5hbWUiOiJEYW5pZWwgT3BwZW5sw6ZuZGVyIFtBdmlhbl0iLCJvaWQiOiI
                      0NmRhZGFlYy01M2Y2LTQyODMtYTM5MC0xOGU5YWZlZDE5YTEiLCJwbGF0ZiI6IjMiLCJwdWlkIjoiMTAwM0JGRkRBNTJFNTZENCIsInNjcCI6IkFjY2Vzc1Jldmlldy5SZWFkLkFsbCBBY2Nlc3NSZXZpZXcuUmVhZFdyaXRl
                      LkFsbCBBZ3JlZW1lbnQuUmVhZC5BbGwgQWdyZWVtZW50LlJlYWRXcml0ZS5BbGwgQWdyZWVtZW50QWNjZXB0YW5jZS5SZWFkIEFncmVlbWVudEFjY2VwdGFuY2UuUmVhZC5BbGwgQWxsU2l0ZXMuUmVhZCBBcHBDYXRhbG9nL
                      lJlYWRXcml0ZS5BbGwgQXVkaXRMb2cuUmVhZC5BbGwgQm9va2luZ3MuTWFuYWdlLkFsbCBCb29raW5ncy5SZWFkLkFsbCBCb29raW5ncy5SZWFkV3JpdGUuQWxsIEJvb2tpbmdzQXBwb2ludG1lbnQuUmVhZFdyaXRlLkFsbC
                      BDYWxlbmRhcnMuUmVhZCBDYWxlbmRhcnMuUmVhZC5BbGwgQ2FsZW5kYXJzLlJlYWQuU2hhcmVkIENhbGVuZGFycy5SZWFkV3JpdGUgQ2FsZW5kYXJzLlJlYWRXcml0ZS5BbGwgQ2FsZW5kYXJzLlJlYWRXcml0ZS5TaGFyZWQ
                      gQ29udGFjdHMuUmVhZCBDb250YWN0cy5SZWFkLkFsbCBDb250YWN0cy5SZWFkLlNoYXJlZCBDb250YWN0cy5SZWFkV3JpdGUgQ29udGFjdHMuUmVhZFdyaXRlLkFsbCBDb250YWN0cy5SZWFkV3JpdGUuU2hhcmVkIERldmlj
                      ZS5Db21tYW5kIERldmljZS5SZWFkIERldmljZU1hbmFnZW1lbnRBcHBzLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRBcHBzLlJlYWRXcml0ZS5BbGwgRGV2aWNlTWFuYWdlbWVudENvbmZpZ3VyYXRpb24uUmVhZC5BbGwgR
                      GV2aWNlTWFuYWdlbWVudENvbmZpZ3VyYXRpb24uUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50TWFuYWdlZERldmljZXMuUHJpdmlsZWdlZE9wZXJhdGlvbnMuQWxsIERldmljZU1hbmFnZW1lbnRNYW5hZ2VkRGV2aW
                      Nlcy5SZWFkLkFsbCBEZXZpY2VNYW5hZ2VtZW50TWFuYWdlZERldmljZXMuUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkLkFsbCBEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkV3JpdGUuQWxsIERldml
                      jZU1hbmFnZW1lbnRTZXJ2aWNlQ29uZmlnLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRTZXJ2aWNlQ29uZmlnLlJlYWRXcml0ZS5BbGwgRGlyZWN0b3J5LkFjY2Vzc0FzVXNlci5BbGwgRGlyZWN0b3J5LlJlYWQuQWxsIERp
                      cmVjdG9yeS5SZWFkV3JpdGUuQWxsIEVBUy5BY2Nlc3NBc1VzZXIuQWxsIEVkdUFkbWluaXN0cmF0aW9uLlJlYWQgRWR1QWRtaW5pc3RyYXRpb24uUmVhZFdyaXRlIEVkdUFzc2lnbm1lbnRzLlJlYWQgRWR1QXNzaWdubWVud
                      HMuUmVhZEJhc2ljIEVkdUFzc2lnbm1lbnRzLlJlYWRXcml0ZSBFZHVBc3NpZ25tZW50cy5SZWFkV3JpdGVCYXNpYyBFZHVSb3N0ZXIuUmVhZCBFZHVSb3N0ZXIuUmVhZEJhc2ljIEVkdVJvc3Rlci5SZWFkV3JpdGUgZW1haW
                      wgRXhjaGFuZ2UuTWFuYWdlIEZpbGVzLlJlYWQgRmlsZXMuUmVhZC5BbGwgRmlsZXMuUmVhZC5TZWxlY3RlZCBGaWxlcy5SZWFkV3JpdGUgRmlsZXMuUmVhZFdyaXRlLkFsbCBGaWxlcy5SZWFkV3JpdGUuQXBwRm9sZGVyIEZ
                      pbGVzLlJlYWRXcml0ZS5TZWxlY3RlZCBGaW5hbmNpYWxzLlJlYWRXcml0ZS5BbGwgZnVsbF9hY2Nlc3NfYXNfdXNlciBHcm91cC5SZWFkLkFsbCBHcm91cC5SZWFkV3JpdGUuQWxsIElkZW50aXR5UHJvdmlkZXIuUmVhZC5B
                      bGwgSWRlbnRpdHlQcm92aWRlci5SZWFkV3JpdGUuQWxsIElkZW50aXR5Umlza0V2ZW50LlJlYWQuQWxsIGlkZW50aXR5cmlza3l1c2VyLnJlYWQuYWxsIE1haWwuUmVhZCBNYWlsLlJlYWQuQWxsIE1haWwuUmVhZC5TaGFyZ
                      WQgTWFpbC5SZWFkV3JpdGUgTWFpbC5SZWFkV3JpdGUuQWxsIE1haWwuUmVhZFdyaXRlLlNoYXJlZCBNYWlsLlNlbmQgTWFpbC5TZW5kLkFsbCBNYWlsLlNlbmQuU2hhcmVkIE1haWxib3hTZXR0aW5ncy5SZWFkIE1haWxib3
                      hTZXR0aW5ncy5SZWFkV3JpdGUgTWVtYmVyLlJlYWQuSGlkZGVuIE5vdGVzLkNyZWF0ZSBOb3Rlcy5SZWFkIE5vdGVzLlJlYWQuQWxsIE5vdGVzLlJlYWRXcml0ZSBOb3Rlcy5SZWFkV3JpdGUuQWxsIE5vdGVzLlJlYWRXcml
                      0ZS5DcmVhdGVkQnlBcHAgTm90aWZpY2F0aW9ucy5SZWFkV3JpdGUuQ3JlYXRlZEJ5QXBwIG9mZmxpbmVfYWNjZXNzIG9wZW5pZCBQZW9wbGUuUmVhZCBQZW9wbGUuUmVhZC5BbGwgUGVvcGxlLlJlYWRXcml0ZSBQb2xpY3ku
                      UmVhZC5BbGwgUG9saWN5LlJlYWRXcml0ZS5Db25kaXRpb25hbEFjY2VzcyBQcml2aWxlZ2VkQWNjZXNzLlJlYWRXcml0ZS5BenVyZUFEIFByaXZpbGVnZWRBY2Nlc3MuUmVhZFdyaXRlLkF6dXJlUmVzb3VyY2VzIHByb2Zpb
                      GUgUHJvZ3JhbUNvbnRyb2wuUmVhZC5BbGwgUHJvZ3JhbUNvbnRyb2wuUmVhZFdyaXRlLkFsbCBSZXBvcnRzLlJlYWQuQWxsIFNlY3VyaXR5RXZlbnRzLlJlYWQuQWxsIFNlY3VyaXR5RXZlbnRzLlJlYWRXcml0ZS5BbGwgU2
                      l0ZXMuRnVsbENvbnRyb2wuQWxsIFNpdGVzLk1hbmFnZS5BbGwgU2l0ZXMuUmVhZC5BbGwgU2l0ZXMuUmVhZFdyaXRlLkFsbCBTdWJzY3JpcHRpb24uUmVhZC5BbGwgVGFza3MuUmVhZCBUYXNrcy5SZWFkLlNoYXJlZCBUYXN
                      rcy5SZWFkV3JpdGUgVGFza3MuUmVhZFdyaXRlLlNoYXJlZCBVc2VyLkV4cG9ydC5BbGwgVXNlci5JbnZpdGUuQWxsIFVzZXIuUmVhZCBVc2VyLlJlYWQuQWxsIFVzZXIuUmVhZEJhc2ljLkFsbCBVc2VyLlJlYWRXcml0ZSBV
                      c2VyLlJlYWRXcml0ZS5BbGwgVXNlckFjdGl2aXR5LlJlYWRXcml0ZS5DcmVhdGVkQnlBcHAgVXNlclRpbWVsaW5lQWN0aXZpdHkuV3JpdGUuQ3JlYXRlZEJ5QXBwIiwic2lnbmluX3N0YXRlIjpbImttc2kiXSwic3ViIjoiN
                      zNyZzI3OEFBVG1uU0ZNS05XMUhJYTduZXduNG5UWUdsYVo1S3Y2cVlxUSIsInRpZCI6ImIxODc1Y2Q4LWEzOWItNDFjNy1hNGE4LTYwMWY0M2M1YTIxMiIsInVuaXF1ZV9uYW1lIjoiZG9wQGF2aWFuLmRrIiwidXBuIjoiZG
                      9wQGF2aWFuLmRrIiwidXRpIjoiUWU0elFodGdkVVdMVVV6UHpvZExBQSIsInZlciI6IjEuMCIsIndpZHMiOlsiNjJlOTAzOTQtNjlmNS00MjM3LTkxOTAtMDEyMTc3MTQ1ZTEwIl0sInhtc190Y2R0IjoxNTA3MTg5ODcyfQ.
                      IvwD1ow-aHTE_OIyiCk7QFmRUAbPY6WaFBdyXouiG7fu8WJxmtgIp2D2yzyzA3P5fAs34PPH7tNcsyOJBWQlUSbTXjML_T5X_Y8xiC0sJlXK5RpQ1ftCicLyo4MuCp7Z5Yx7V7Q3yLZ5hIYuAMBa_jbAzBqM9tOnqR8pa56fx
                      DLanqqikJVJ5cpEemZRc4QyY2B9shbIpxlu9r5kokkbzkDguaPT-jrPtLivlKr8MuCZ11ToDHTdjqj78S6mjR7PoWV649knPoBoVUzSdvUzxHi6XskwyYheQtmQQsF6Q0T_1lntsbbPoogDaFi-xH83KwVn7INhpGUkl0GQUw
                      -BMw
                        Content-Type: application/json; charset=utf-8
                        Content-Length: 26
                      }
IsSuccessStatusCode : False



Getting the message "The sharing message is not supported." while sharing the calendar using ews managed api.

$
0
0

                                                                                            

  public void ShareCalendar(Calendar calendar)
        {           
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
              service.Credentials = new NetworkCredential("user1", "password", "domain");
            service.Url = new Uri("https://sampleUrl/ews/exchange.asmx");

            try
            {
                // Bind to the folder
                //Folder folderStoreInfo;
                //folderStoreInfo = Folder.Bind(service, calendar.ExchangeId);
                //string EwsID = folderStoreInfo.Id.UniqueId;
                string EwsID = calendar.FolderExchangeId;

                // The value of folderidHex will be what we need to use for the FolderId in the xml file

                AutodiscoverService autoDiscover = new AutodiscoverService(ExchangeVersion.Exchange2013);
                autoDiscover.Credentials =  new NetworkCredential("user1", "password", "domain");
                autoDiscover.RedirectionUrlValidationCallback = RedirectionUrlValidationCallback;


                Dictionary<string, string> userSettings = GetUserSettings(autoDiscover);

                string folderidHex = GetConvertedEWSIDinHex(service, EwsID, "user1@outlook.com");

                string domainName = string.Empty;
                string mailBoxServer = string.Empty;
                string userName = string.Empty;
                foreach (var item in userSettings)
                {
                    switch (item.Key)
                    {
                        case "UserDN":
                            domainName = item.Value.ToString();
                            break;
                        case "InternalMailboxServer":
                            mailBoxServer = item.Value.ToString();
                            break;
                        case "UserDisplayName":
                            userName = item.Value.ToString();
                            break;
                    }
                }

                string entryId = GetIntiatorEntryID(domainName);

                string mailboxId = GetInvitationMailboxId(mailBoxServer, domainName);


                string sharedFilePath = CreateSharingMessageAttachment(folderidHex, userName, entryId, mailboxId, "user2@outlook.com", "calendar", calendar.FolderName);



                // Create a new message
                EmailMessage invitationRequest = new EmailMessage(service);
                invitationRequest.Subject = "I'd like to share my calendar with you";
                invitationRequest.Body = "Sent by Exchange Administrator on behalf of user";                
                //invitationRequest.Culture = "en-US";
                invitationRequest.Sensitivity = Sensitivity.Normal;

                // Set a sharing specific property on the message
                invitationRequest.ItemClass = "IPM.Sharing"; /* Constant Required Value [MS-ProtocolSpec] */

                byte[] byteEntryId = HexStringToByteArray(entryId);

                // This is the Guid of the Sharing Provider in Exchange, and it's value does not change
                Guid binSharingProviderGuid = new Guid("{AEF00600-0000-0000-C000-000000000046}");

                // Even though I don't think setting this property is mandatory, 
                // it just seemed like the right thing to do and it works so I \
                // ain't messin with it!                                        
                byte[] byteSharingProviderGuid = binSharingProviderGuid.ToByteArray();

                string strPRBODYHTML = "<html dir=\"ltr\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\r\n<meta name=\"GENERATOR\" content=\"MSHTML 8.00.7601.17514\">\r\n<style id=\"owaParaStyle\">P {\r\n   MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px \r\n}\r\n</style>\r\n</head>\r\n<body fPStyle=\"1\" ocsi=\"0\">\r\n<tt>\r\n<pre>SharedByUserDisplayName (SharedByUserSmtpAddress) has invited you to view his or her Microsoft Exchange Calendar.\r\n\r\nFor instructions on how to view shared folders on Exchange, see the following article:\r\n\r\nhttp://go.microsoft.com/fwlink/?LinkId=57561\r\n\r\n*~*~*~*~*~*~*~*~*~*\r\n\r\n</pre>\r\n</tt>\r\n<div>\r\n<div style=\"direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;\">this is a test message</div>\r\n</div>\r\n</body>\r\n</html>\r\n";

                string strBODY = @"
SharedByUserDisplayName (SharedByUserSmtpAddress) has invited you to view his or
her Microsoft Exchange Calendar.

For instructions on how to view shared folders on Exchange, see the
following article:

http://go.microsoft.com/fwlink/?LinkId=57561

*~*~*~*~*~*~*~*~*~*


test body

";
                // Convert these to hex and binary equivelants to assign to their relevant
                // extended properties
                string hexPRBODYHTML = ConvertStringToHex(strPRBODYHTML);
                byte[] binPRBODYHTML = HexStringToByteArray(hexPRBODYHTML);

                Guid PropertySetSharing = Guid.Parse("00062040-0000-0000-C000-000000000046");//constant 
                Guid PropertySetInternetHeaders = Guid.Parse("00020386-0000-0000-C000-000000000046");//constant

                ExtendedPropertyDefinition PidLidSharingProviderGuidProperty = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A01, MapiPropertyType.CLSID);
                ExtendedPropertyDefinition ConversationIdProperty = new ExtendedPropertyDefinition(0x3013, MapiPropertyType.Binary);


                // Sharing Properties (in order of reference according to protocol examples in: [MS-OXSHARE])

                // Additional Property Constraints
                // [MS-OXSHARE] 2.2.5.2
                ExtendedPropertyDefinition PidTagMessageClass = new ExtendedPropertyDefinition(0x001A, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.5.1
                //ExtendedPropertyDefinition PidNameContentClass = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "Content-Class", MapiPropertyType.String);
                ExtendedPropertyDefinition PidNameContentClass = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "Content-class", MapiPropertyType.String);

                // Common Message Object Properties               
                // [MS-OXSHARE] 2.2.1
                ExtendedPropertyDefinition PidTagNormalizedSubject = new ExtendedPropertyDefinition(0x0E1D, MapiPropertyType.String);
                // The PidTagSubjectPrefix is a zero-length string, so I do not set it
                // ExtendedPropertyDefinition PidTagSubjectPrefix = new ExtendedPropertyDefinition(0x003D, MapiPropertyType.String);

                // Sharing Object Message Properties
                // [MS-OXSHARE] 2.2.2.12
                ExtendedPropertyDefinition PidLidSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A01, MapiPropertyType.Binary);
                // [MS-OXSHARE] 2.2.2.13
                ExtendedPropertyDefinition PidNameXSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-GUID", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.14
                ExtendedPropertyDefinition PidLidSharingProviderName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A02, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.15           
                ExtendedPropertyDefinition PidNameXSharingProviderName = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-Name", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.16
                ExtendedPropertyDefinition PidLidSharingProviderUrl = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A03, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.17
                ExtendedPropertyDefinition PidNameXSharingProviderUrl = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-URL", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.5
                ExtendedPropertyDefinition PidLidSharingFlavor = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A18, MapiPropertyType.Integer);
                // [MS-OXSHARE] 2.2.2.6
                ExtendedPropertyDefinition PidNameXSharingFlavor = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Flavor", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.1
                ExtendedPropertyDefinition PidLidSharingCapabilities = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A17, MapiPropertyType.Integer);
                // [MS-OXSHARE] 2.2.2.2
                ExtendedPropertyDefinition PidNameXSharingCapabilities = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Capabilities", MapiPropertyType.String);
                // Sections 2.3 and 2.4 are also zero-length strings, so I won't set those either
                // [MS-OXSHARE] 2.2.2.3
                // ExtendedPropertyDefinition PidLidSharingConfigurationUrl = new   //ExtendedPropertyDefinition(PropertySetSharing, 0x8A24, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.4
                //ExtendedPropertyDefinition PidNameXSharingConfigUrl = new //ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Config-Url", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.10
                ExtendedPropertyDefinition PidLidSharingLocalType = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A14, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.11
                ExtendedPropertyDefinition PidNameXSharingLocalType = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Local-Type", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.7
                ExtendedPropertyDefinition PidLidSharingInitiatorEntryId = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A09, MapiPropertyType.Binary);
                // [MS-OXSHARE] 2.2.2.8
                ExtendedPropertyDefinition PidLidSharingInitiatorName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A07, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.2.9
                ExtendedPropertyDefinition PidLidSharingInitiatorSMTP = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A08, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.3.1
                ExtendedPropertyDefinition PidLidSharingRemoteName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A05, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.3.2 
                ExtendedPropertyDefinition PidNameXSharingRemoteName = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Name", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.3.5 
                ExtendedPropertyDefinition PidLidSharingRemoteType = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A1D, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.3.6 
                ExtendedPropertyDefinition PidNameXSharingRemoteType = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Type", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.3.7 
                ExtendedPropertyDefinition PidLidSharingRemoteUid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A06, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.3.8 
                ExtendedPropertyDefinition PidNameXSharingRemoteUid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Uid", MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.3.3
                ExtendedPropertyDefinition PidLidSharingRemoteStoreUid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A48, MapiPropertyType.String);
                // [MS-OXSHARE] 2.2.3.4
                ExtendedPropertyDefinition PidNameXSharingRemoteStoreUid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Store-Uid", MapiPropertyType.String);






                //From troubleshooting I noticed I was missing
                ExtendedPropertyDefinition PidTagPriority = new ExtendedPropertyDefinition(0x0026, MapiPropertyType.Integer);
                ExtendedPropertyDefinition PidTagSensitivity = new ExtendedPropertyDefinition(0x0036, MapiPropertyType.Integer);
                ExtendedPropertyDefinition PR_BODY_HTML = new ExtendedPropertyDefinition(0x1013, MapiPropertyType.Binary); //PR_BOD
                ExtendedPropertyDefinition PR_BODY = new ExtendedPropertyDefinition(0x1000, MapiPropertyType.String);
                ExtendedPropertyDefinition RecipientReassignmentProhibited = new ExtendedPropertyDefinition(0x002b, MapiPropertyType.Boolean);


                // Section 2.2.1
                invitationRequest.SetExtendedProperty(PidTagNormalizedSubject, "I'd like to share my calendar with you"); /* Constant Required Value [MS-OXSHARE] 2.2.1 */
                //invitationRequest.SetExtendedProperty(PidTagSubjectPrefix, String.Empty); /* Constant Required Value [MS-OXSHARE] 2.2.1 */
                // Section 2.2.2
                invitationRequest.SetExtendedProperty(PidLidSharingCapabilities, 0x40220); /* value for Special Folders */
                invitationRequest.SetExtendedProperty(PidNameXSharingCapabilities, "40220"); /* Test representation of SharingCapabilities value */
                //invitationRequest.SetExtendedProperty(PidLidSharingConfigurationUrl, String.Empty); /* Zero-Length String [MS-OXSHARE] 2.2.2.3 */
                //invitationRequest.SetExtendedProperty(PidNameXSharingConfigUrl, String.Empty); /* Zero-Length String [MS-OXSHARE] 2.2.2.4 */
                invitationRequest.SetExtendedProperty(PidLidSharingFlavor, 0x20310); /* Indicates Invitation for a special folder [MS-OXSHARE] 2.2.2.5 */
                invitationRequest.SetExtendedProperty(PidNameXSharingFlavor, "20310"); /* Text representation of SharingFlavor value [MS-OXSHARE] 2.2.2.6 */
                invitationRequest.SetExtendedProperty(PidLidSharingInitiatorEntryId, byteEntryId); /* Value from the Initiator/EntryId value in the Sharing Message attachment .xml document */
                invitationRequest.SetExtendedProperty(PidLidSharingInitiatorSMTP, "user1@outlook.com"); /* Value from Initiator/Smtp Address in the Sharing message attachment .xml document */
                invitationRequest.SetExtendedProperty(PidLidSharingInitiatorName, "User1"); /* Value from Initiator/Name Address in the Sharing message attachment .xml document */
                invitationRequest.SetExtendedProperty(PidLidSharingLocalType, "IPF.Appointment"); /* MUST be set to PidTagContainerClass of folder to be shared */
                invitationRequest.SetExtendedProperty(PidNameXSharingLocalType, "IPF.Appointment"); /* MUST be set to same value as PidLidSharingLocalType */
                invitationRequest.SetExtendedProperty(PidLidSharingProviderGuid, byteSharingProviderGuid); /* Constant Required Value [MS-OXSHARE] 2.2.2.12 */
                invitationRequest.SetExtendedProperty(PidNameXSharingProviderGuid, "AEF0060000000000C000000000000046"); /* Constant Required Value [MS-OXSHARE] 2.2.2.13 */
                invitationRequest.SetExtendedProperty(PidLidSharingProviderName, "Microsoft Exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.14 */
                invitationRequest.SetExtendedProperty(PidNameXSharingProviderName, "Microsoft Exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.15] */
                invitationRequest.SetExtendedProperty(PidLidSharingProviderUrl, "http://www.microsoft.com/exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.16 */
                invitationRequest.SetExtendedProperty(PidNameXSharingProviderUrl, "http://www.microsoft.com/exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.17 */
                // Section 2.2.3
                invitationRequest.SetExtendedProperty(PidLidSharingRemoteName, calendar.FolderName); /* MUST be set to PidTagDisplayName of the folder being shared */
                invitationRequest.SetExtendedProperty(PidNameXSharingRemoteName, calendar.FolderName); /* MUST be set to same value as PidLidSharingRemoteName */
                invitationRequest.SetExtendedProperty(PidLidSharingRemoteStoreUid, mailboxId); /* Must be set to PidTagStoreEntryId of the folder being shared */
                invitationRequest.SetExtendedProperty(PidNameXSharingRemoteStoreUid, mailboxId); /* MUST be set to same value as PidLidSharingRemoteStoreUid */
                invitationRequest.SetExtendedProperty(PidLidSharingRemoteType, "IPF.Appointment"); /* Constant Required Value [MS-OXSHARE] 2.2.3.5 */
                invitationRequest.SetExtendedProperty(PidNameXSharingRemoteType, "IPF.Appointment"); /* Constant Required Value [MS-OXSHARE] 2.2.3.6 */
                invitationRequest.SetExtendedProperty(PidLidSharingRemoteUid, folderidHex); /* MUST be set to PidTagEntryId of folder being shared */
                invitationRequest.SetExtendedProperty(PidNameXSharingRemoteUid, folderidHex); /* Must be set to same value as PidLidSharingRemoteUid */
                // Section 2.2.5
                invitationRequest.SetExtendedProperty(PidNameContentClass, "Sharing"); /* Constant Required Value [MS-ProtocolSpec] */
                invitationRequest.SetExtendedProperty(PidTagMessageClass, "IPM.Sharing"); /* Constant Required Value [MS-ProtocolSpec] */


                // ********* ADDITIONAL MAPPED PROPERTIES IM FINDING AS I TROUBLESHOOT ********************** //
                invitationRequest.SetExtendedProperty(PidTagPriority, 0); /* From troubleshooting I'm just trying to match up values that were missing */
                invitationRequest.SetExtendedProperty(PidTagSensitivity, 0); /* From troubleshooting as well */
                invitationRequest.SetExtendedProperty(PR_BODY_HTML, binPRBODYHTML); /* From troubleshooting OWA error pointing to serializing HTML failing */
                invitationRequest.SetExtendedProperty(PR_BODY, strBODY);
                invitationRequest.SetExtendedProperty(RecipientReassignmentProhibited, true); /* Because it seemed like a good idea */

                // Add a file attachment by using a stream
                // We need to do the following in order to prevent 3 extra bytes from being prepended to the attachment
                string sharMetadata = File.ReadAllText(sharedFilePath, Encoding.ASCII);
                byte[] fileContents;
                UTF8Encoding encoding = new System.Text.UTF8Encoding();
                fileContents = encoding.GetBytes(sharMetadata);
                //fileContents = File.ReadAllBytes(sharedFilePath);

                //// fileContents is a Stream object that represents the content of the file to attach.
                invitationRequest.Attachments.AddFileAttachment("sharing_metadata.xml", fileContents);

                ////invitationRequest.Attachments.AddFileAttachment(sharedFilePath);
                //// This is where we set those "special" headers and other pertinent
                //// information I noted in Part 1 of this series...
                //Attachment thisAttachment = invitationRequest.Attachments[0];
                //thisAttachment.ContentType = "application/x-sharing-metadata-xml";
                //thisAttachment.Name = "sharing_metadata.xml";
                //thisAttachment.IsInline = false;

                // Add recipient info and send message
                invitationRequest.ToRecipients.Add(new EmailAddress() { Address = "user2@outlook.com" });


                invitationRequest.SendAndSaveCopy();

                // I always end my methods by returning the EWS 
                // impersonated user to null to clean up
                service.ImpersonatedUserId = null;

            }
            catch (Exception ex)
            {

            }
        }

        public String GetConvertedEWSIDinHex(ExchangeService esb, String sID, String strSMTPAdd)
        {
            // Create a request to convert identifiers.
            AlternateId objAltID = new AlternateId();
            objAltID.Format = IdFormat.EwsId;
            objAltID.Mailbox = strSMTPAdd;
            objAltID.UniqueId = sID;

            //Convert  PR_ENTRYID identifier format to an EWS identifier.
            AlternateIdBase objAltIDBase = esb.ConvertId(objAltID, IdFormat.HexEntryId);
            AlternateId objAltIDResp = (AlternateId)objAltIDBase;
            return objAltIDResp.UniqueId.ToString();
        }

        public String GetInvitationMailboxId(string mailBoxServer, string domainName)
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
            service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "user1@outlook.com");
            // Generate The Store Entry Id for the impersonated user
            StringBuilder MailboxIDPointer = new StringBuilder();          
            string fqdn = mailBoxServer;
            string legacyDN = domainName;


            MailboxIDPointer.Append("00000000"); /* Flags */
            MailboxIDPointer.Append("38A1BB1005E5101AA1BB08002B2A56C2"); /* ProviderUID */
            MailboxIDPointer.Append("00"); /* Version */
            MailboxIDPointer.Append("00"); /* Flag */
            MailboxIDPointer.Append("454D534D44422E444C4C00000000"); /* DLLFileName */
            MailboxIDPointer.Append("00000000"); /* Wrapped Flags */
            MailboxIDPointer.Append("1B55FA20AA6611CD9BC800AA002FC45A"); /* WrappedProvider UID (Mailbox Store Object) */
            MailboxIDPointer.Append("0C000000"); /* Wrapped Type (Mailbox Store) */
            MailboxIDPointer.Append(ConvertStringToHex(fqdn)); /* ServerShortname (FQDN) */
            MailboxIDPointer.Append("00"); /* termination bit */
            MailboxIDPointer.Append(ConvertStringToHex(legacyDN)); /* Returns the userDN of the impersonated user */
            MailboxIDPointer.Append("00"); /* terminator bit */


            service.ImpersonatedUserId = null;
            return MailboxIDPointer.ToString();

        }

        static bool RedirectionUrlValidationCallback(String redirectionUrl)
        {
            bool redirectionValidated = false;
            if (redirectionUrl.Equals("https://SampleUrl/autodiscover/autodiscover.xml"))          
            {
                redirectionValidated = true;
            }
            return redirectionValidated;
        }

        public String GetIntiatorEntryID(string domainName)
        {
            String result = String.Empty;

            //// Bind to EWS
            //ExchangeService service = ExchangeConnection.ExchangeService();
            //service.ImpersonatedUserId =
            //new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "user1@outlook.com");

            //// Get LegacyDN Using the function above this one 

            string sharedByLegacyDN = domainName;
            // A conversion function from earlier
            string legacyDNinHex = ConvertStringToHex(sharedByLegacyDN);



            StringBuilder addBookEntryId = new StringBuilder();



            addBookEntryId.Append("00000000"); /* Flags */
            addBookEntryId.Append("DCA740C8C042101AB4B908002B2FE182"); /* ProviderUID */
            addBookEntryId.Append("01000000"); /* Version */
            addBookEntryId.Append("00000000"); /* Type - 00 00 00 00  = Local Mail User */
            addBookEntryId.Append(legacyDNinHex); /* Returns the userDN of the impersonated user */
            addBookEntryId.Append("00"); /* terminator bit */


            result = addBookEntryId.ToString();
            //service.ImpersonatedUserId = null;
            return result;
        }

        public string ConvertStringToHex(string input)
        {
            // Take our input and break it into an array
            char[] arrInput = input.ToCharArray();
            String result = String.Empty;

            // For each set of characters
            foreach (char element in arrInput)
            {               
                if (String.IsNullOrEmpty(result))
                {
                    result = String.Format("{0:X2}", Convert.ToUInt16(element)).ToString();
                }
                else
                {
                    result += String.Format("{0:X2}", Convert.ToUInt16(element)).ToString();
                }

            }
            return result.ToString();
        }

 public string CreateSharingMessageAttachment(string folderid, string userSharing, string userSharingEntryID, string invitationMailboxID, string userSharedTo, string dataType, string calendarName)
        {
            XmlDocument sharedMetadataXML = new XmlDocument();
            string sharedMetaDataFilePath = string.Empty;
            try
            {

                // Create a String that contains our new sharing_metadata.xml file
                StringBuilder metadataString = new StringBuilder("<?xml version=\"1.0\"?>");              
                metadataString.Append("<SharingMessage xmlns=\"http://schemas.microsoft.com/sharing/2008\">");
                metadataString.Append("<DataType>" + dataType + "</DataType>");
                metadataString.Append("<Initiator>");
                metadataString.Append("<Name>" + userSharing + "</Name>");
                metadataString.Append("<SmtpAddress>" + "Shyam@ProConstructor.com" + "</SmtpAddress><EntryId>" + userSharingEntryID.Trim());
                metadataString.Append("</EntryId>");
                metadataString.Append("</Initiator>");
                metadataString.Append("<Invitation>");
                metadataString.Append("<Title>" + calendarName + "</Title>");
                metadataString.Append("<Providers>");
                metadataString.Append("<Provider Type=\"ms-exchange-internal\" TargetRecipients=\"" + userSharedTo + "\">");
                metadataString.Append("<FolderId xmlns=\"http://schemas.microsoft.com/exchange/sharing/2008\">");
                metadataString.Append(folderid);
                metadataString.Append("</FolderId>");
                metadataString.Append("<MailboxId xmlns=\"http://schemas.microsoft.com/exchange/sharing/2008\">");
                metadataString.Append(invitationMailboxID);
                metadataString.Append("</MailboxId>");
                metadataString.Append("</Provider>");
                metadataString.Append("</Providers>");
                metadataString.Append("</Invitation>");
                metadataString.Append("</SharingMessage>");
               
                sharedMetadataXML.LoadXml(metadataString.ToString());
             
                string tempPath = System.IO.Path.GetTempPath();

                sharedMetaDataFilePath = tempPath + "sharing_metadata.xml";
                sharedMetadataXML.Save(sharedMetaDataFilePath);

            }
            catch (Exception eg)
            {
                throw eg;               
            }
            return sharedMetaDataFilePath;
        }



        public Dictionary<string, string> GetUserSettings(AutodiscoverService autodiscoverService)
        {


            GetUserSettingsResponse userresponse = autodiscoverService.GetUserSettings(
                "user1@outlook.com",
                UserSettingName.UserDisplayName,
                UserSettingName.InternalMailboxServerDN,
                UserSettingName.UserDN
            );

            Dictionary<string, string> myUserSettings = new Dictionary<string, string>();

            foreach (KeyValuePair<UserSettingName, Object> usersetting in userresponse.Settings)
            {

                if (usersetting.Key.ToString() == "InternalMailboxServerDN")
                {
                    int lastIndexOfEqual = usersetting.Value.ToString().LastIndexOf("=");
                    string subString = usersetting.Value.ToString().Substring(lastIndexOfEqual + 1);

                    string value = subString;
                    myUserSettings.Add("InternalMailboxServer", value.ToString());

                }
                if (usersetting.Key.ToString() == "UserDisplayName")
                {
                    string[] arrResult = usersetting.Value.ToString().Split('.');

                    myUserSettings.Add("UserDisplayName", arrResult[0].ToString());

                }
                if (usersetting.Key.ToString() == "UserDN")
                {
                    string[] arrResult = usersetting.Value.ToString().Split('.');

                    myUserSettings.Add("UserDN", arrResult[0].ToString());

                }
            }

            return myUserSettings;
        }

        private static byte[] HexStringToByteArray(string input)
        {

            byte[] Bytes;

            int ByteLength;

            string HexValue = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9|||||||\xA\xB\xC\xD\xE\xF";

            ByteLength = input.Length / 2;

            Bytes = new byte[ByteLength];

            for (int x = 0, i = 0; i < input.Length; i += 2, x += 1)
            {
                Bytes[x] = (byte)(HexValue[Char.ToUpper(input[i + 0]) - '0'] << 4);
                Bytes[x] |= (byte)(HexValue[Char.ToUpper(input[i + 1]) - '0']);
            }

            return Bytes;
        }



Connect to internal exchange server powershell?

$
0
0

Hi

I have this script: 

$messages = Import-Csv -Path c:\temp\123.csv

Connect-EXRMailbox -Mailbox "testmail@test.com"
ForEach ($message in $messages){
$MessageId = $message.messageID
$MailboxName = $message.Email
    $Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId 
     Set-EXRItemCategory -MailboxName $MailboxName -Item $Item -Categories @("YAAAAAAAS")

}

But i did only test it on my office 365 account. I now want to use it for internal exchange server.

Is it possible so it looks up my internal exchange IP instead of "https://login.microsoftonline.com/common/oauth2/authorize?resource=https%3A%2F%2FGraph.Microsoft.com&client_id=5471030d-f311-4c5d-91ef-74ca885463a7&response_type=code&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&prompt=refresh_session" 

Right now when i use the script, i cant login, as its not connected to my internal exchange server.


Exchange Web Service Managed Api - Save an email as an msg to disk

$
0
0
Hi,
I am trying to save an email that I have retrieved via the EWS managed Api but get the following message when I try and open the file.

"Cannot open file c:\bla\bin... The file may not exist, you may not have permission to open it, or it may be open in another program. Right-click the folder that contails the file, and then click Properties to check your permissions for the folder."

Any help will be much appriciated.

See code below:

public static void save_entire_email_to_disk()
{
    ExchangeService service = GetService();

    var findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(10));
    foreach (var result in findResults)
    {
        if (result is EmailMessage)
        {
            var message = result as EmailMessage;
            message.Load(new PropertySet(ItemSchema.MimeContent));
           
            MimeContent mc = message.MimeContent;
            FileStream oFileStream = new FileStream("Test.msg", FileMode.Create);

            oFileStream.Write(mc.Content, 0, mc.Content.Length);
            oFileStream.Close();
        }
    }
}

Cheers,

Zi

Need API for messageTrace

$
0
0

Hi , i need to get message trace from the search pattern provided by the user.

MSDN has provided to do it from the UI provided "protection.office.com". I tried using same, but getting 440(timeout) error from my mvc application. Below link has more info on message trace. I need API to call it from my application. 

https://support.office.com/en-us/article/message-trace-in-the-office-365-security-compliance-center-3e64f99d-ac33-4aba-91c5-9cb4ca476803?ui=en-US&rs=en-US&ad=US

Thankyou in advance.


EWS Script to change categories, from CSV

$
0
0
Hello :)

Is there a way to add categories to emails on an Onprem versions of Exchange, via EWS script, from an CSV?


I tried to look around on blogs, here on the forum and other sites, but cant seem to find anything.

Best Regards

Pixiline

Hybrid environment; Exchanger server 2016 and Microsoft Office 365

$
0
0

hello Friends, I have a fully functional domain and active directory and using exchange server 2016. I want to know, can I used Microsoft office 365 as a loadbalancer. Can I make DAG with two different platform. Its kind of hybrid. Is it too difficult to configure two different platform. I need all relevant information. 

Yous answers will highly appreciated. Thanks in advanced

MSExchangeIS Mailbox Counters Messages Deliverd and Local Deliveries

$
0
0

Hi,

I've been collecting performance data on Exchange 2013 for the following MSExchangeIS Mailbox counters:

  • Messages Delivered
  • Local Deliveries

I note both counters are reporting the same values.  I assumed that local deliveries would be less than Messages Delivered.  The counter descriptions don't really help much.

Anyone have any thoughts?

EWS Copy Item Response doesn't return new id's

$
0
0

Hi,

I am using the CopyItems method from EWS to copy mails from one mailbox to another. I pass the boolean return new id's as true. But new id's are not returned. In the MSDN documentation I see this comment

The Item property is a null reference (Nothing in Visual Basic) if the copy operation was between two mailboxes or between a mailbox and a public folder.

So this means I can never get the new id's? 

Outlook REST API - equivalent of Managed EWS API SendInvitationsOrCancellationsMode for AppointmentItems

$
0
0

Hello Techies,

I am new to Outlook REST API area and looking for an option to silently update outlook calendar meetings. I know that this can be achieved using Managed EWS API using SendInvitationsOrCancellationsModevalues. Is there any similar option in Outlook REST API?

Please advise.

Thanks.



sureshh...


getting last modifier from an invitation

$
0
0

Hi,

I am trying to find out the last modifier of an appointment by using EWS, but i do not want to use actual appointment to get this instead i want to get it through as a property of  invitation sent. 

is it possible? 

Thanks

I am Unable to Set response type for attendee(Accept,Deny,Unknown) of an event using EWS jar

$
0
0

Hi Team, 

I am unable to set the response type of a calendar event using EWS jar. 

I can find method like getResponseType() to get the response of attendee for an event(Accept,Unknown,Deny).

But I couldn't find any suitable method to set the response.

Kindly help me out in this regard

Thanks


exchange2010sp3 i want to operating exchange management shell by python,how can i do ?

$
0
0

i use C# using System.Management.Automation; to Remote operation exchange management shell

such as move DB、new mailbox...

here is my code :

using System.Management.Automation;using System.Management.Automation.Runspaces;privatestaticstring adminUser = @"contoso\administrator";privatestaticstring adminPwd = "password";public WSManConnectionInfo mailexloginin(){
	SecureString ssRunasPassword = new SecureString();
        foreach (char x in adminPwd)
        {
        	ssRunasPassword.AppendChar(x);
         }
	PSCredential credentials = new PSCredential(adminUser, ssRunasPassword);
        var connInfo = new WSManConnectionInfo(new Uri("http://192.168.0.1/PowerShell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credentials);
	connInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;return connInfo;
}


but now i want to use python to  Achieve this demand

I can't find a library for this.

I don't know how the above code is implemented.

I noticed a url:

var connInfo = new WSManConnectionInfo(new Uri("http://192.168.0.1/PowerShell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credentials);

how can i use this url to do something?

One painful requirement of how to create calendar group by EWS API?

$
0
0
Our product manager proposed one painful requirement regarding of adding shared calendar group through EWS API and joined related email account into shared calendar group, I have googled all documents internet around two days,  I still could not figure out how to do it eventually.

Error uninstalling Exchange 2016

$
0
0

Error:
The following error was generated when "$error.Clear();
          if (Get-Service MpsSvc* | ?{$_.Name -eq 'MpsSvc'})
          {
            Set-Service MpsSvc -StartupType Automatic
            Start-SetupService -ServiceName MpsSvc
          }
        " was run: "Microsoft.PowerShell.Commands.ServiceCommandException: Service 'Windows Defender Firewall (MpsSvc)' cannot be configured due to the following error: Access is denied ---> System.ComponentModel.Win32Exception: Access is denied
   --- End of inner exception stack trace ---".

Can't uninstall Exchange 2016. Help needed. Thanks

Viewing all 7132 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>