# How to Setup Email Outlook

Saat ini kami menyediakan integrasi antara 3Dolphins dengan outlook email. Untuk dapat melakukan integrasi tersebut, sebelumnya Anda harus memenuhi persyaratan minimum berikut ini:

* Anda harus sudah memiliki email bisnis.
* Email tersebut harus sudah berlangganan Office 365.

### Create App Registration on Microsoft Azure

Setelah memastikan bahwa Anda telah memenuhi persyaratan minimum diatas, silahkan buat app registration pada microsoft azure. Pertama, masuk ke halaman <https://portal.azure.com/#home> menggunakan akun email bisnis Anda.&#x20;

<figure><img src="https://3286717921-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlqWTLEMUin8jixjPTHF7%2Fuploads%2FtNGyfgnJiUe1VXMVaEeF%2FWelcome%20To%20Azure.png?alt=media&#x26;token=0c1aaf17-61d2-4395-8974-e2198c848cb9" alt=""><figcaption><p>Dashboard Portal Azure</p></figcaption></figure>

Kemudian, buka menu **App Registrations**. Pada halaman app registrations, klik tombol **'+ New Registration'.**

<figure><img src="https://3286717921-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlqWTLEMUin8jixjPTHF7%2Fuploads%2FNllszglcFc2eFyXT5T9r%2Fnew%20registration%20new%20edit.png?alt=media&#x26;token=3f950f26-a35b-43d0-9ec5-d3faf01c7ec4" alt=""><figcaption><p>New Registration</p></figcaption></figure>

Masukkan informasi pendaftaran aplikasi Anda:

1. **Name**: Masukkan nama aplikasi yang akan ditampilkan kepada user.
2. Pilih opsi **Accounts in any organizational directory and personal Microsoft accounts**dari bagian **Supported account types**.
3. Pilih platform **'Web'** dan isi URL dengan https\://\[url]/dolphin/channel/authorization/channel-email-outlook.xhtml

Kemudian, klik tombol **'Register**' untuk membuat aplikasi.

<figure><img src="https://3286717921-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlqWTLEMUin8jixjPTHF7%2Fuploads%2Fr3PJ2A0lRaMak5MKWAx5%2FRegister%20application%20edit.png?alt=media&#x26;token=83b9e573-081c-4445-8c49-8c324218e47a" alt=""><figcaption><p>Register Application</p></figcaption></figure>

Setelah beberapa saat, pendaftaran aplikasi yang baru berhasil dibuat akan terbuka.

<figure><img src="https://3286717921-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlqWTLEMUin8jixjPTHF7%2Fuploads%2FYPldzPTy49RW8upKO2UZ%2Fsuccess%20register%20application%20edit.png?alt=media&#x26;token=d93284ae-bdd6-4e53-b774-fb09e70034e0" alt=""><figcaption><p>Created App Registration</p></figcaption></figure>

{% hint style="info" %}
Simpan informasi app Anda berupa Client ID dan juga Tenant ID.&#x20;
{% endhint %}

Setelah itu, buat client crediantials Anda dengan mengklik tombol **'Add a certificate or secret'**. Kemudian, klik tombol **'New client secret'**.

<figure><img src="https://3286717921-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlqWTLEMUin8jixjPTHF7%2Fuploads%2Fo44npoDX74qdNrFup41M%2FNew%20client%20secret.png?alt=media&#x26;token=b378f66a-e3c7-45d2-be3f-9b65a557a91d" alt=""><figcaption><p>Add Client Secret </p></figcaption></figure>

Pada dialog yang muncul, masukkan deskripsi opsional untuk client secret Anda dan pilih periode expired dari tombol drop-down list Expires, lalu klik tombol **'Add'**.

<figure><img src="https://3286717921-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlqWTLEMUin8jixjPTHF7%2Fuploads%2F79f4JkVhwnMjbkzhfEKE%2Fadd%20client%20secret.png?alt=media&#x26;token=b0329b22-3731-415a-a0ba-2dd4875cada3" alt=""><figcaption><p>Add Client Secret</p></figcaption></figure>

Client secret Anda sudah berhasil terbuat. Perlu diingat, untuk menyimpan value dan tanggal expired dari client secret tersebut.&#x20;

<figure><img src="https://3286717921-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlqWTLEMUin8jixjPTHF7%2Fuploads%2FlBijG2Qf1uAhNn75mO2y%2Fsuccess%20add%20client%20secret%20edit.png?alt=media&#x26;token=975536b4-9e58-49db-9e91-a25a3e1cd1e7" alt=""><figcaption><p>Client Secret Added</p></figcaption></figure>

{% hint style="warning" %}
Simpan **"value"** dikarenakan hanya muncul satu kali. Jika Anda lupa menyalinnya, Anda harus membuat ulang client secret kembali.
{% endhint %}

### Modify IMAP & SMTP Via Windows Powershell

Setelah berhasil membuat aplikasi azure, Anda harus memodifikasi IMAP & SMTP email tersebut via windows powershell, sehingga email tersebut memilki akses lengkap. Berikut merupakan command untuk memodifikasi di masing-masing sistem operasi.&#x20;

#### Windows OS&#x20;

Pertama, buka windows powershell sebagai Administrator. Kemudian, masukkan command berikut.

<pre class="language-powershell"><code class="lang-powershell">Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
<strong>Install-Module -Name ExchangeOnlineManagement
</strong>Install-Module Microsoft.Graph 
Import-module ExchangeOnlineManagement
Install-Module -Name AzureADPreview
</code></pre>

Kemudian, klik Enter dan masukkan Y. Tunggu sampai installing package selesai lalu masukkan command berikutnya.&#x20;

```powershell
Connect-AzureAD -TenantId <your tenant id>
```

Login menggunakan alamat email bisnis Anda dan masukkan password. Tunggu sampai proses selesai. Kemudia, masukkan command berikut.&#x20;

{% code overflow="wrap" %}

```powershell
Connect-ExchangeOnline -Organization <your tenant id> 
```

{% endcode %}

Lalu, login kembali menggunakan email bisnis Anda. Setelah berhasil connect masukkan data aplikasi ke variabel dengan cara:

```powershell
$MyApp = Get-AzureADServicePrincipal -SearchString "your app name"
```

{% code overflow="wrap" %}

```powershell
New-ServicePrincipal -AppId $MyApp.AppId -ServiceId $MyApp.ObjectId -DisplayName "Service Principal for IMAP"
```

{% endcode %}

{% code overflow="wrap" %}

```powershell
Add-MailboxPermission -Identity yourbusinessemail@microsoft.com -User $MyApp.ObjectId -AccessRights FullAccess
```

{% endcode %}

Jika Anda sudah sampai langkah ini maka, channel email Anda sudah dapat menerima inbound email. Berikut merupakan command untuk mendapatkan akses penuh untuk outbound email.

{% code overflow="wrap" %}

```powershell
Set-CASMailbox -Identity yourbusinessemail@mailmicrosoft.com -SmtpClientAuthenticationDisabled $false
Set-CASMailbox -Identity yourbusinessemail@mailmicrosoft.com -IMAPEnabled $true
```

{% endcode %}

#### Mac OS

Bila sistem operasi Anda menggunakan Mac, Anda harus menginstall powershell terlebih dahulu dengan menggunakan command berikut pada terminal.&#x20;

```shell
brew install --cask powershell
```

Lalu, buka windows powershell dan masukkan command berikut.

```powershell
Register-PSRepository -Default
Install-Module -Name ExchangeOnlineManagement -allowprerelease
Install-Module Microsoft.Graph -allowprerelease
Install-Module -Name Az
Import-module ExchangeOnlineManagement
```

Kemudian, klik Enter dan masukkan Y. Tunggu sampai installing package selesai lalu masukkan command berikutnya.

```powershell
Connect-AzAccount -Tenant <your tenant id>  
```

Lalu, login kembali menggunakan email bisnis Anda. Setelah berhasil connect masukkan data aplikasi ke variabel dengan cara:

```powershell
Connect-ExchangeOnline -Organization <your tenant id> 
```

Lalu, login kembali menggunakan email bisnis Anda. Setelah berhasil connect masukkan data aplikasi ke variabel dengan cara:

```powershell
$MyApp = Get-AzADServicePrincipal -SearchString "your app name"
```

{% code overflow="wrap" %}

```powershell
New-ServicePrincipal -AppId $MyApp.AppId -ServiceId $MyApp.Id -DisplayName "Service Principal for IMAP"
```

{% endcode %}

{% code overflow="wrap" %}

```powershell
Add-MailboxPermission -Identity yourbusinessemail@microsoft.com -User $MyApp.Id -AccessRights FullAccess
```

{% endcode %}

Jika Anda sudah sampai langkah ini maka, channel email Anda sudah dapat menerima inbound email. Berikut merupakan command untuk mendapatkan akses penuh untuk outbound email.

{% code overflow="wrap" %}

```powershell
Set-CASMailbox -Identity yourbusinessemail@mailmicrosoft.com -SmtpClientAuthenticationDisabled $false
Set-CASMailbox -Identity yourbusinessemail@mailmicrosoft.com -IMAPEnabled $true
```

{% endcode %}
