this is the script i used.....also in the html file the config was imagedata src = cid:image001.jpg for
each instance of image.
this is the error i receive
The cmdlet extension agent with the index 5 has thrown an exception in OnComplete(). The exception is: Microsoft.Exchange.Provisioning.ProvisioningException: ScriptingAgent: Exception thrown while invoking scriptlet for OnComplete API: You cannot call
a method on a null-valued expression.. ---> System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression. at CallSite.Target(Closure , CallSite , Object , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite
site, T0 arg0, T1 arg1) at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) --- End of inner exception stack trace
--- at Microsoft.Exchange.ProvisioningAgent.ScriptingAgentHandler.OnComplete(Boolean succeeded, Exception e) at Microsoft.Exchange.Provisioning.ProvisioningLayer.OnCompleteImpl(Task task, Boolean succeeded, Exception exception)
<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="Welcome Email" Cmdlets="New-Mailbox,Enable-Mailbox">
<ApiCall Name="OnComplete">
if($succeeded) {
if ($provisioningHandler.TaskName -eq "New-Mailbox") {
# Replace place holder.
$USRdname=$provisioningHandler.UserSpecifiedParameters["Name"]
$tempmsg= [string] (get-content ("c:\Welcomemsg\WelcomeMSG.htm"))
$tempmsg = $tempmsg -replace "NewUser00",$USRdname
# Picking Primary SMTP address,saving to $pSMTP to send email.
$Ualias=$provisioningHandler.UserSpecifiedParameters["Alias"]
$pSMTP = (get-mailbox $Ualias | select-object PrimarySMTPAddress | Format-Wide | Out-String ).trim()
}
elseif ($provisioningHandler.TaskName -eq "Enable-Mailbox") {
# Picking Primary SMTP address,saving to $epSMTP to send email.
$eUalias=$provisioningHandler.UserSpecifiedParameters["Alias"]
$dName = (get-mailbox $eUalias | select-object Name | Format-Wide | Out-String ).trim()
$pSMTP = (get-mailbox $eUalias | select-object PrimarySMTPAddress | Format-Wide | Out-String ).trim()
# Replace place holder.
$tempmsg= [string] (get-content ("c:\welcomemsg\welcomemsg.htm"))
$tempmsg = $tempmsg -replace "NewUser00",$dName
}
# Please give the correct HUB serve IP address in the following line.
$HUBServer="10.180.1.10"
$EMail =new-object net.mail.mailmessage
$HUBTask = new-object net.mail.smtpclient($HUBServer)
# Add any linked resources (e.g. images)
$image = New-Object System.Net.Mail.LinkedResource("C:\Welcomemsg\image001.jpg")
$image.ContentId = "image001.jpg"
$image.ContentType = "image/jpg"
$view.LinkedResources.Add($image)
$image = New-Object System.Net.Mail.LinkedResource("C:\Welcomemsg\image002.jpg")
$image.ContentId = "image002.jpg"
$image.ContentType = "image/jpg"
$view.LinkedResources.Add($image)
# Email with link will be sent from the address given in the following line.
$EMail.From="Administrator@lab.com"
# Email with link will be sent TO the address given in the following line.
$EMail.To.add($pSMTP)
# Email Subject and Body details are speficied in following lines
$EMail.Subject="Welcome"
$EMail.Body= $tempmsg
$Email.IsBodyHtml = $true
$HUBTask.send($EMail)
}
</ApiCall>
</Feature>
</Configuration>
-
Edited by
OgeJessy
16 hours 9 minutes ago