locked
Welcome Email issues RRS feed

  • Question

  • Hi

    I am trying to send a Welcome Email when a new email box is created. Everything works fine in terms of the mailbox receiving the email.

    The process I am following is described here:

    https://blogs.msdn.microsoft.com/emeamsgdev/2014/07/23/exchange-automating-a-welcome-email-to-new-users/

    The issue is this.

    When I insert one image, it works perfect and the welcome email shows the image in the email.

    The problem occurs when I insert more than one.

    Here is code snippit

     # Obtain the message text
            $messageText = [string](Get-Content ("d:\scripts\welcome email\newwelcome.htm")) # Change to point to your HTML welcome message
            $messageText = $messageText.Replace("#UserFirstName#", $usr.FirstName) # This replaces #UserFirstName# with the user's first name - you can add further replacements as needed
    
            # Create the HTML view for this message
            $view = [System.Net.Mail.AlternateView]::CreateAlternateViewFromString($messageText, $null, "text/html")
    
            # Add any linked resources (e.g. images)
            $image = New-Object System.Net.Mail.LinkedResource("d:\scripts\welcome email\image002.jpg")
            $image.ContentId = "image002.jpg"
            $image.ContentType = "image/jpg"
            $view.LinkedResources.Add($image)
    		
            $image12 = New-Object System.Net.Mail.LinkedResource("d:\scripts\welcome email\image012.jpg")
            $image.ContentId = "image012.jpg"
            $image.ContentType = "image/jpg"
            $view.LinkedResources.Add($image12)
    		

    With this codethe email ends up like this:

    The email comes through with the pictures missing and these attachments.

    If the code specifies only one picture it works fine and the email generates with that one image no problem.

    Am I doing something incorrect in the code?

    Thanks

    Friday, June 2, 2017 3:59 PM

All replies

  • Hello,

    Base on your description and screenshot, I suppose that the picture will display normally if click "Click Here" in this message. Figure as below:

    If it's OWA client, there's a feature to block some external content in HTML messages, such as pictures.
    More details, refer to:
    https://blogs.technet.microsoft.com/catastrophic_failure_joannav/2013/04/26/how-to-turn-off-blocked-feature-in-owa-outlook-web-app/

    Similar with Junk Email Filter feature in Outlook client.

    Therefore, I want to confirm whether the sender you are used to send message, if it's an authenticated mailbox and it should be working fine.

    Best Regards,

    Allen Wang


    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, June 5, 2017 8:59 AM
  • Here is the code for sending the email:

      


            # Create the objects we need to create the message and send the mail
            $message = New-Object System.Net.Mail.MailMessage
            $smtpClient = New-Object System.Net.Mail.SmtpClient("smtp.abc.com") # Change this to point to your SMTP server
    
    # Create the message
            $message.From = "welcome@hybrid.local" # Update this to the address you want the welcome message to be sent from
            $message.To.Add($mbx.PrimarySmtpAddress.ToString())
            $message.Subject = "Welcome to email!" # Update this to your email subject
            $message.AlternateViews.Add($view)
            $message.IsBodyHtml = $true
    
            # Send the message
            $smtpClient.Send($message)
    It's just using Exchange as a relay to send. Can this be modified to authenticate? and therefor not block the pictures?

    Monday, June 5, 2017 2:23 PM
  • Yes, we can configure a mail contact which use this connector as external address.

    Best Regards,

    Allen Wang


    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, June 6, 2017 3:23 AM