How to send a message with Send-MailMessage cmdLet powershell exchange which uses a html file as a parameter

Before the mailboxes migration E2003 toward E2010 SP2, I have to send a mail which body already exists as a html file.
Here the powershell I currently use :
import-csv d:\path\TestLot.csv  | foreach {Send-MailMessage -To $_.PrimarySmtpAddress -From
[email protected] -Subject "Migration " -body "Your mailbox Migration will start in 2 days." -SmtpServer servXXX}
And it is allright !
But, I was asked to use an existing html file instead of my poor : -body "Your mailbox Migration will start in 2 days." 
Does anybody know the way to do this ?
Thank you for your help
PATMOY
BOAT

Hi,
I have the html code in a variable so i can personalize the mails:
$htmlcode = '<html><body style="background:#FFFFFF"><head><title>Activaion email</title></head>'
$htmlcode += '<style type="text/css">'
$htmlcode += '#HLine { font-size:20px; font-family:Verdana; font-weight: bold; }'
$htmlcode += '#txt { font-size:12px; font-family:Verdana;}'
$htmlcode += '</style>'
$htmlcode += '<img src="/img/HBPMAN0aGcc.gif" width="52" height="52" />&nbsp;&nbsp;&nbsp;<br />'
$htmlcode += '<h1 id="HLine">Your BlackBerry account has been created ...</h1>'
$htmlcode += '<div id="txt"><strong>... Your User Data:</strong><br />'
$htmlcode += '&nbsp;&nbsp;&nbsp;<br /><table border="0" id="txt"><tr><td>&nbsp;&nbsp;<strong>Username:</strong></td><td>'+$UsrData.Email+'</td></tr>'
$htmlcode += '<tr><td>&nbsp;&nbsp;<strong>Activation Password:</strong></td><td>'+$UsrData.pass+'</td></tr></table><br />'
$htmlcode += '<strong>The activation credentials are valid for just 5 days after receipt of this email!</strong><br /><br/ >'
$htmlcode += '<strong>... Next Steps: </strong><br /><br />'
$htmlcode += '<a href= "/bb/doc/EN.pdf">- Activate your Device</a>&nbsp;<br />'
$htmlcode += '&nbsp;&nbsp;To be able to use your new BlackBerry you need to complete this steps.<br /><br />'
$htmlcode += '<a href= "/bb/doc/Tips.pdf">- Tips and Tricks for your Device</a><br />'
$htmlcode += '&nbsp;&nbsp;Tips and Tricks to make your Device experience a success.<br /><br />'
$htmlcode += '<strong>... in case you require technical support:</strong><br /><br />'
$htmlcode += 'If you experiance problems with your Device, please contact your local IT-Support.<br /><br />'
$htmlcode += 'Thank You.'
$htmlcode += '<br/><div></body></html>'
Send-MailMessage -to $UsrData.Email -From $from -Body $htmlcode -SmtpServer $smtp -Subject $subject -BodyAsHtml
If you want to make sure the mail is displayed as a HTML Mail add to the send-mailmessage the option
-BodyAsHtml
Regards
Dan

Similar Messages

  • How to send a message with javamail api

    Hi, anybody can tell me how i do to send a message with javamail?
    Thanks.
    Daniele.

    [rossifumi80],
    Here's a simple JavaMail application SendMessage.java that will connect a SMTP host and send a mail message out:
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class SendMessage {
      public static void main (String args[]) throws Exception {
        String host = args[0];
        String from = args[1];
        String to = args[2];
        // Get system properties
        Properties props = System.getProperties();
        // Setup mail server
        props.put("mail.smtp.host", host);
        // Get session
        Session session = Session.getDefaultInstance(props, null);
        // Define message
        MimeMessage message = new MimeMessage(session);
        // Set the from address
        message.setFrom(new InternetAddress(from));
        // Set the to address
        message.addRecipient(Message.RecipientType.TO,
          new InternetAddress(to));
        // Set the subject
        message.setSubject("Hello JavaMail");
        // Set the content
        message.setText("Welcome to JavaMail");
        // Send message
        Transport.send(message);
    }HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • HT2589 What if I have an iPhone and its sends/recieves messages with our apple id which is my moms email? How do I fix that so that when I text my friends it doesn't show up with my moms email but my number?

    What if I have an iPhone and its sends/recieves messages with our apple id which is my moms email? How do I fix that so that when I text my friends it doesn't show up with my moms email but my number?

    Hi lfeddrix,
    You can send and receive Messages from the Apple IDs and phone numbers signed in to your iMessage section in the settings of your phone. We have an article that explains a little bit about this, and it can be found here:
    iOS: Using Messages
    http://support.apple.com/kb/ht3529
    This section is the most appropriate for your situation:
    You can change the address that new iMessage conversations are started with in Settings > Messages > Send & Receive > Start new conversations from:. Note that this setting applies only to new conversations. If you would like to change the address from which messages are sent, first change this setting, and then delete the existing conversation and start a new one.
    iMessage responses will be sent from the address the recipient most recently messaged. For example, a friend sends you a message to your Apple ID. Responses in this conversation will be sent from your Apple ID, even if you've selected new conversations to start from your phone number.
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • HT3529 WHEN I SEND A MESSAGE WITH VIDEO, THE PERSON RECEIVING THE MESSAGE HAS NO SOUND TO THE VIDEO .hOW DO I FIX THE PROBLEM..THANKS

    WHEN I SEND A MESSAGE WITH VIDEO, THE PERSON RECEIVING THE MESSAGE HAS NO SOUND TO THE VIDEO .hOW DO I FIX THE PROBLEM..THANKS

    is there sound when you play the video yourself?

  • How to send SOAP Message with Oracle B2B

    Hi everyone,
    I need your help to send out from Oracle B2B a SOAP message with attachment of any type of file (image, pdf, etc.). Possibly using a SOA composite application or another way, it doesn't matter. I already create an ebMS partnership with a custom document protocol and I already create a working SOA composite application to send only text message to my trading partner. I have tried this solution: http://anuj-dwivedi.blogspot.it/2011/04/ebms-attachment-handling-in-oracle-b2b.html but it doesn't work for my case... It is to be noticed that I don't give any schema to my component in the SOA application explained firstly, and I select opaque as schema.
    Thanks to all, regards
    Nello

    Hi Anuj and thanks for your help,
    I need to send an ebXML message, with SOAP, and I try to send it with a .war application written in jsp connecting to http://10.85.28.24:8001/b2b/transportServlet to send the SOAP message. The errors reported is:
    javax.xml.soap.SOAPException: Unable to receive message. Received a response from url: http://10.85.28.24:8001/b2b/transportServlet with HTTP status 200 and SOAP content-type: null.
    the code I write is the following (to evaluate the two "null" in the super constructor)
    <%!
    public class EBMSSender extends SOAPRunner
    private String cpaId;
    private String service;
    private String action;
    private String mess;
    private ArrayList<String> allegati=null;
    public EBMSSender(String cpaId, String service, String action, String mess, ArrayList<String> file)
    super("http://10.85.28.24:8001/b2b/transportServlet","null", "null");
    this.cpaId = cpaId;
    this.service = service;
    this.action = action;
    this.mess=mess;
    this.allegati=file;
    @Override
    protected void prepareRequest(SOAPMessage soapMessage, SOAPBody soapBody) throws SOAPException
    soapBody.addChildElement(SOAPUtility.createElement("CPAId", getNsPrefix(), getNsURI(),"agr3"));
    soapBody.addChildElement(SOAPUtility.createElement("service", getNsPrefix(), getNsURI(),"OracleService"));
    soapBody.addChildElement(SOAPUtility.createElement("action", getNsPrefix(), getNsURI(),"Oracletohermesb"));
    soapBody.addChildElement(SOAPUtility.createElement("serviceType", getNsPrefix(), getNsURI(),"OracleServiceType"));
    soapBody.addChildElement(SOAPUtility.createElement("convId", getNsPrefix(), getNsURI(), "convId"));
    soapBody.addChildElement(SOAPUtility.createElement("fromPartyId", getNsPrefix(), getNsURI(), "Oracle"));
    soapBody.addChildElement(SOAPUtility.createElement("fromPartyType", getNsPrefix(), getNsURI(), "Name"));
    soapBody.addChildElement(SOAPUtility.createElement("toPartyId", getNsPrefix(), getNsURI(), "Hermes-b"));
    soapBody.addChildElement(SOAPUtility.createElement("toPartyType", getNsPrefix(), getNsURI(), "Name"));
    attach(soapMessage);
    protected void attach(SOAPMessage soapMessage)
    String h=mess;
    DataHandler dh;
    AttachmentPart ap = soapMessage.createAttachmentPart(h,"text/plain");
    soapMessage.addAttachmentPart(ap);
    if(allegati!=null)
    for(int i=0; i<allegati.size();i++)
    dh=new DataHandler(new FileDataSource(new File(allegati.get(i))));
    ap=soapMessage.createAttachmentPart(dh);
    ap.setContentType(new MimetypesFileTypeMap().getContentType(allegati.get(i)));
    ap.setContentLocation(allegati.get(i));
    soapMessage.addAttachmentPart(ap);
    @Override
    protected void processFault(SOAPFault soapFault) throws SOAPException{}
    @Override
    protected Object processResponse(SOAPMessage responseMessage,SOAPBody responseBody) throws SOAPException
    SOAPElement messageId = SOAPUtility.getChild(responseBody, "message_id", getNsURI());
    return null;
    %>
    The code works fine on the other trading partner side to send ebXML message to Oracle B2B. Apart from this solution (however,it would be my favorite), I find your blog and I try to implement your solution. It works: it sends files with only text payload to the other trading partner without any problem, but if I try to send for example an image in byte array written in a file .txt, the ebxml file received has the byte array with wrong characters. it may be that I have not provided the xsd schema? in case if I wanted to send an ebXML message with text and attachments, what xsd schema do I need to provide?
    or is there another way to implement a SOA composite application to send SOAP messages with attachments?
    Thank for your help!, regards
    Nello

  • Send Sip Message with UDP transpot

    How to make to send a message with transport UDP?
    Message was edited by:
    nicvas

    Though the doMessage is being invoked on the server, the exception would arise when the server fails to send the message to the callee.
    Check if there is any callee listening on: 192.168.1.104:1,107. Thats where the server is trying to send the message.
    Make sure 2 text clients are running and have registered with the chat server before sending the message from one to the other.
    hope this helps,
    mihir

  • Is there a way to send a message with a photo attached using imessages. I am not able to send a photo to one of my contacts because I am sending the contact a message text messages. I don't want to send contacts text messages. I want to send them iMe

    Is there a way to send a message with a photo attached using imessages. I am not able to send a photo to one of my contacts because I am sending the contact a message text messages. I don't want to send contacts text messages. I want to send them iMessages.

    Kolyei, sorry for the late reply.
    Have your brother create a contact in his phone for himself. Inside his own contact, have him add his phone number and his iCloud address.
    Settings > Messages > Send & Receive Have your brother select both his phone number and email addresses where he would like to receive iMessages.

  • When I send an email with Mail, I often confuse the account which I'm using. The result is that I send a message with the wrong account! Is there a way to avoid this (for example a reminder before the email is sent)?

    When I send an email with Mail, I often confuse the account which I'm using. The result is that I send a message with the wrong account! Is there a way to avoid this (for example a reminder before the email is sent)?

    Hi, thanks for the answer, I did that already. Unfortunatly this doesn't help me at all, as I often forget to check the menu. For me composing the message is writing the text, the subject, the person to who is addressed and than press "send".
    I often forget to check the "from", and this is a problem because the software select itself one of the accounts.
    Isn't there a way at least to put as a default a blank field instead of one of the accounts? or an account which doesn't work so if I forget to specify the "from" I will be rnotofied that the message can't be sent.
    I guess this could be a rather common problem for many people!
    Thanks
    Sergio

  • Since i instaled ios 6 , i send a message with my iphone and i receive in my ipad. what is happening?

    since i instaled ios 6 , i send a message with my iphone and i receive in my ipad. what is happening?

    Sounds like it is using your Apple ID / Associated Emails to receive the iMessage. This means that the person who is replying is making it go to your email address. Make sure that the person you are sending the iMessage to has an iPhone as well. I don't remember if other iOS devices can send iMessages to a mobile phone number.

  • Why do I get an attaching message when sending a message with embedded pictures.

    Sometimes when I try to send a message with embedded images, I get a message stating "Status: Attaching . . . with a green Progress: bar that appears to be 100% but still running". The problem is that it never goes away and the message is never sent.

    Do you have MMS turned on? Do you have a data connection?

  • My wife iphone has trouble sending a messages with a picture

    My wifes iphone has trouble sending a message with a picture or texting a picture, Is this a setting problem ?

    http://support.apple.com/kb/TS2755?viewlocale=en_US&locale=en_US

  • CANNOT send SMS messages with ADDRESS BOOK on POWERBOOK using iPHONE

    I cannot send SMS messages with my address book or dial phone numbers using my Powerbook via the iPHONE.
    Previously, with my Sony Ericson phone, I could do both. It's very useful, when you are at your laptop, to use your computer keyboard to send SMS text messages back and forth rather than using the clumsy small keys on a phone.
    Can someone help?
    Is there something I am missing?
    Message was edited by: Host

    You are not missing something here and no one here can help you. This is not an included Bluetooth profile with the iPhone at the present time anyway.
    If you purchased your iPhone within the last 14 days, you can return it for credit less a 10% restocking fee and if not, here is Apple's feedback link for the iPhone.
    http://www.apple.com/feedback/iphone.html

  • HT5622 Why can I send a message with an attached photo to one contact on phone or email and can't to another contact. I can sent message on iPhone still I was using messages on iPad

    Why can I send message on iPad messages to one contact and not send same message with same photo to another contact. I can sent message on iPhone to same contact

    I would guess that the problem contact does not have iMessage turned on. The iPad can only send iMessages not SMS messages (phone text). You can send a message to this contact with your iPhone because your iPhone can send SMS text messages.

  • Cannot send any message with my N95

    I cannot send any message with my nokia n95 phone. It says "Memory full. Close some programs and try again" where in fact, and I'm very much sure that there's no any program running.
    What memory is referred here? What's happening to my phone? What should I do then? I've been restoring my phone's factory settings since the problem occured yet the problem is still there. Please help me with it's been quite a long time since this problem started to annoy me. Thank you.

    I am having this exact same issue with my N82. Very frustrating. Only way to send a message is via MMS. Also I am not receiving all the messages people are sending me. Are others having this issue as well?

  • TS4461 unable to send pic messages with my old ipad

    unable to send picture messages with older ipad. I have been receiving pic messages and sending & receiving regular txt but can't send pic messages out.
    I'm thinking I have a setting wrong. Please help!

    Hello Jane,
    Thanks for using Apple Support Communities.
    Please follow the troubleshooting steps in the support article linked to below in order to resolve this issue you're experiencing with your iPad:
    iOS: Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Take care,
    Alex H.

Maybe you are looking for

  • Using Numbers, I need to time-stamp each line in a table for when it was entered

    I need to time-stamp each line in a table for when it was entered. I have a formula which is "=IF(F18="","",NOW())" it gives me the answer I want, but every time I edit any data in the formula is recalculates the date/time to reflect the most recent

  • Open website alias in non-default browser

    I have Firefox set as my default browser. I want to set up an alias on my machine to go to a website, but so it will open in Chrome for just that alias. Can you do that on Macs?

  • Java 2 Standard Edition and no Javac

    I'm new to java, so I just grabbed the latest development kit, 1.4, and installed it. It was going through the tutorial when I discovered I was missing a pretty imporant peice, the compiler. I tried reinstalling, as well as installing 1.4.1, and I st

  • Using multiple img src / with htmlText --display problem

    I need help. I am using multiple <img src /> tag with htmlText and pictures displays in layers(overlay)? html_txt.html = true; html_txt.htmlText = "text<br><img src = ' http://picture1.jpg 'width='500' height='491' hspace='0' /><br>more text<br><img

  • AE CS6 on Windows8: H.264 Coded generated very strange frame rates when rendering

    funny things are happening: I import 300 jpegs (canon 6D raw exported from LR as jpeg at max quality) create a new composition (with 25fps) render video in h.264 @25 fps videos rendering works fine, plays well at external player. drag and drop video