Dec 12 2018 09:52 AM
Dec 12 2018 09:52 AM
Is there a way to customize guest invitation emails, as pr. now a lot of our clients/users sees the invitation as some kind of spam and ignore it. It will help if we can customize the invitasjon to include our branding and customized text..ect
Dec 12 2018 09:55 AM
Dec 12 2018 07:25 PM - edited Dec 12 2018 07:26 PM
The service desk staff runs the script, which prompts for external user First/Last Names & email address, as well as the UPN/Email of the requestor. It sends a customized rich-text email invitation to the external user by importing a prepped HTML file, sets the External user Acct's 'manager' field as the requester (for auditing/reporting) and notifies the original requester that the invitation has been sent. Comments need to be improved, but look for the text in between the < & > values to see what you'll need to provide.
# Collected parameters/variables passed in through script switches.
[string] [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] $ExUserEmail=$(Throw "Please provide the external user e-mail address."),
[string] [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] $ExUserLastName=$(Throw "Please provide the external user's Last name."),
[string] [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] $ExUserFirstName=$(Throw "Please provide the external user's First name."),
[string] [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] $Manager=$(Throw "Please provide the e-mail address of the requestor.")
$EmailBody = Get-Content <HTML SOURCE FILE TO BE PLACED IN BODY OF EMAIL-Create Your Own Content> -Raw
# Connect to Azure AD using PW stored in encrypted txt file - Or, use your own credential meethod
$TenantUname = "<USERID@DOMAIN.COM">
$TenantPass = cat "<PATH TO ENCRYPTED PW TXT FILE" | ConvertTo-SecureString
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $TenantUname, $TenantPass
Connect-AzureAD -Credential $Credential
# Send customized guest user email invite
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
$messageInfo.customizedMessageBody = "Please click on the 'Get Started' link below to setup your Guest Account. This account can be used to login to SharePoint sites that a <COMPANYNAME> employee gives you access to."
New-AzureADMSInvitation -InvitedUserEmailAddress $ExUserEmail -InvitedUserDisplayName $ExUserLastName', '$ExUserFirstName -InviteRedirectUrl <SETUP IN AAD> -InvitedUserMessageInfo $messageInfo -SendInvitationMessage $true
# Set 'Manager' field of guest user account to requester.
$ExUserObjectId = (Get-AzureADUser -Filter "Mail eq '$ExUserEmail'").ObjectID
$ManagerObjectId = (Get-AzureADUser -ObjectId $Manager).ObjectId
$ManagerEmail = (Get-AzureADUser -ObjectId $Manager).Mail
Set-AzureADUserManager -ObjectID $ExUserObjectId -RefObjectId $ManagerObjectId
# Send Notification/Confirmation E-Mail To Requester Letting them know that invitation has been sent.
#$bodyText = $body | convertTo-HTML | Out-String
#Sending the email to the requestor/manager.
Send-MailMessage -From '<FROMADDRESS@DOMAIN.COM' -To "$ManagerEmail" -Subject "CONFIRMATION: The External User Account You Requested Has Been Created." -BodyAsHTML -body $EmailBody -smtpserver <SMTPRELAYServer.Domain.com>
Dec 12 2018 07:31 PMSolution
Re-reading your request, my solution isn't quite what you're wanting, but I think if you specify something clear/obvious in the subject as well as the 'From' address it should get you where you need to be and minimize any spam/junk problems.
Also, this is what gets sent to the users who request an external acct be created:
The Office 365 External User Account that you requested has been created, and an invitation has been sent to the email address you provided.
Please contact the Service Desk if you require assistance.
Do not reply to this email, as it was automatically generated and sent from an unmonitored address.