Send Email with HTML format in Outlook Macro

I can use the following to send email with HTML format in VBA. I also have created an HTML file. Is there a way to load the file into .HTMLBody to send it as HTML format message?
    Set OutlookApp = CreateObject("Outlook.Application")
    Set objMail = OutlookApp.CreateItem(olMailItem)
    With objMail
       .BodyFormat = olFormatHTML
       .HTMLBody = "<HTML><BODY>Enter the message text here. </BODY></HTML>"
       .Display
    End With

Try: 
Dim fso As Scripting.FileSystemObject
Dim htmlFile As Scripting.TextStream
Set fso = New Scripting.FileSystemObject
Set htmlFile = fso.OpenTextFile("C:\path\to\my-html-file.htm")
strInsert = htmlFile.ReadAll
then change:
.htmlbody = strInsert
oh, and you need to set a reference to the Scripting runtime in Tools, References. 
Diane Poremsky [MVP - Outlook]
Outlook & Exchange Solutions Center
Outlook Tips
Subscribe to Exchange Messaging Outlook weekly newsletter

Similar Messages

  • Send Email in HTML Format with Javamail.

    GOD BE BLESSED!
    Hello dudes,
    i create a jsp page let me send emails from a database using the API Javamail.
    But these emails when i send then, goes in text format only, and i want to send emails in HTML format too. Anyone can help me?
    I think the Javamail API can send in HTML format.
    thanks and sorry, my english is basic but i think you understand. ;)
    Adler Medrado

    I was trying to do the same thing...I found this on the java.sun.com website somewhere. Hope it works out for you.
    try {
    String host = "";
    String from = "";
    String to = "";
    String fileAttachment = fileName;
    // Get system properties
    Properties props = new Properties();
    // Setup mail server
    props.put("mail.smtp.host", host);
    // Get session
    Session session1 =
    Session.getInstance(props, null);
    // Define message
    MimeMessage message =
    new MimeMessage(session1);
    message.setFrom(
    new InternetAddress(from));
    message.addRecipient(
    Message.RecipientType.TO,
    new InternetAddress(to));
    message.setSubject("");
    // create the message part
    MimeBodyPart messageBodyPart =
    new MimeBodyPart();
    //fill message
    messageBodyPart.setText("");
    Multipart multipart = new MimeMultipart();
    multipart.addBodyPart(messageBodyPart);
    // Part two is attachment
    messageBodyPart = new MimeBodyPart();
    DataSource source =
    new FileDataSource(fileAttachment);
    messageBodyPart.setDataHandler(
    new DataHandler(source));
                   messageBodyPart.setFileName(fileAttachment);
    multipart.addBodyPart(messageBodyPart);
    // Put parts in message
    message.setContent(multipart);
    // Send the message
    Transport.send( message );
    }catch (Exception e){
    System.err.print("Mailing error:");
    System.err.println(e);

  • Java.mail sending email in html format

    I trying to send emails from my java program, I ve managd to send text mails, I want to send email in html format is there a way of doing that and how
    thanks for your help

    Thanks a lot it is working now but I think that sending mails in text format is the best way since there isn't a way of knowing whether the recepient can handel html mails

  • Sending email in html format.

    i am trying to send email in html format. the following is my sample code. it's just sending plain text. how should i send html file in email?
    String message_body = "<a href=\"test.html\">click here</a>";
    MimeMessage msg = new MimeMessage( session );
    // From Address
    msg.setFrom( new InternetAddress( fromAddress ) );
    // TO Address
    InternetAddress recipient_Address = new InternetAddress( toAddress );
    msg.addRecipient(Message.RecipientType.TO, recipient_Address);
    // Subject
    msg.setSubject( subject );
    // MimeBodyPart object for message body part
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText( message_body );
    // MimeBodyPart object for file to attach
    MimeBodyPart mbp2 = new MimeBodyPart();
    Multipart mp = new MimeMultipart();
    // create the Multipart and add message body and file to attach.
    mp.addBodyPart(mbp1);
    // add the Multipart to the message
    msg.setContent(mp);
    msg.setSentDate(new Date());
    // send the message
    Transport.send(msg);
    i'd appreciated it...

    msg.setContent(mp, "text/html");Have I put this in the right place? You need to apply it to your body text, at any rate.

  • Send emails in html format

    Hi All,
    My requirement is to send emails. I am using javamail and it works fine. But the body of the email should be in table format.
    I am planning to use Html as below. But don't know how to combine html in java. Is there any other way of achieving it ? Please let me know if I am not clear.
    <htm>
    <table border="1">
    <tr>
    <td bgcolor="red">Header</td>
    </tr>
    <tr>
    <td bgcolor="yellow">Sub Header1</td>
    <td bgcolor="yellow">Sub Header1</td>
    </tr>
    <tr>
    <td bgcolor="green">Values</td>
    <td bgcolor="green">Values</td>
    </tr>
    </html>

    so, do I need another method which tells Java whereto output the HTML Tags ?
    The method writes to a PrintWriter defined somewhere,
    you can also pass the PrintWriter as third argument
    to the method.
    To generate a String containg the whole HTML Dokument
    you would write something like:
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new
    PrintWriter(stringWriter);
    writeStartTable();
    writeStartRow();
    writeCell("BlaBla", "green");
    printEndTable();
    printWriter.flush();
    printWriter.close();
    stringWriter.close();
    String content = stringWriter().toString();
    BodyPart mailBody = new MimeBodyPart();
    mailBody.setContent(content, "text/html");
    I was succesful in sending mail using HTML format. Thanks for ur reply.
    But if I try send the mail in HTML format along with an attachment, the MIME type defaults to "text/plain".
    Is there a way to set the MIME type to "text/html" when I send mail with an attachment.
    Please help . Let me know if I am not clear

  • Send email in html format

    Hello everybody,
    First of all:
    I already searched via internet but couldn´t found an example which helped me to solve my problem. Anyway I believe it must be very simple what I want to do.
    My Problem: I want to send an email in html format, but until now everything I tried didn´t worked. Please help me. What do I have to do?
    I already tried a lot of code typing. For example this one:
    this.resolveNode("#event").submit.target="mailto:"+email_adressen+"subject="+subject+"&Body="+body+"&MessageFormat=HTML";
    But nothing is working, you always see the html tags in the text - they have no effect at all :-( .
    Best regards,
    Paolo

    I was trying to do the same thing...I found this on the java.sun.com website somewhere. Hope it works out for you.
    try {
    String host = "";
    String from = "";
    String to = "";
    String fileAttachment = fileName;
    // Get system properties
    Properties props = new Properties();
    // Setup mail server
    props.put("mail.smtp.host", host);
    // Get session
    Session session1 =
    Session.getInstance(props, null);
    // Define message
    MimeMessage message =
    new MimeMessage(session1);
    message.setFrom(
    new InternetAddress(from));
    message.addRecipient(
    Message.RecipientType.TO,
    new InternetAddress(to));
    message.setSubject("");
    // create the message part
    MimeBodyPart messageBodyPart =
    new MimeBodyPart();
    //fill message
    messageBodyPart.setText("");
    Multipart multipart = new MimeMultipart();
    multipart.addBodyPart(messageBodyPart);
    // Part two is attachment
    messageBodyPart = new MimeBodyPart();
    DataSource source =
    new FileDataSource(fileAttachment);
    messageBodyPart.setDataHandler(
    new DataHandler(source));
                   messageBodyPart.setFileName(fileAttachment);
    multipart.addBodyPart(messageBodyPart);
    // Put parts in message
    message.setContent(multipart);
    // Send the message
    Transport.send( message );
    }catch (Exception e){
    System.err.print("Mailing error:");
    System.err.println(e);

  • Blank email with HTML format

    when I get an email in HTML format on my phone , the message comes in whiteand occasionally get the html code unencrypted. i use Iphone 6 and my email server its Exchange server 2010 on premise.
    I hope you can help me.

    Try: 
    Dim fso As Scripting.FileSystemObject
    Dim htmlFile As Scripting.TextStream
    Set fso = New Scripting.FileSystemObject
    Set htmlFile = fso.OpenTextFile("C:\path\to\my-html-file.htm")
    strInsert = htmlFile.ReadAll
    then change:
    .htmlbody = strInsert
    oh, and you need to set a reference to the Scripting runtime in Tools, References. 
    Diane Poremsky [MVP - Outlook]
    Outlook & Exchange Solutions Center
    Outlook Tips
    Subscribe to Exchange Messaging Outlook weekly newsletter

  • Problems sending emails with iPhone 3G and outlook exchange

    I have a problem sending email with exchange. Receiving and answering mail works fine and calender updates work fine. However when I initiate an email from the phone it syncs and ends up in the sent folder in the computer but never reaches the recipient. I have tried this many times with different recipients and phones. It only happens from my iphone and ipad. Any suggestions?
    Any help much appreciated

    The iPhone you returned is still syncing against your server and locking out your account. Someone possibly has access to your mail data. I'd recommend having your Exchange Administrator install the Microsoft Exchange Server ActiveSync Web Administration Tool (http://www.microsoft.com/downloads/details.aspx?FamilyID=E6851D23-D145-4DBF-A2CC -E0B4C6301453&displaylang=en) and attempt to wipe/delete/block that other iPhone.
    Message was edited by: ethanm

  • Send email in html format with pdf attachment

    I am trying to send an email out of SAP using an abap program in the html format with a pdf attachment. I am using the function module -SO_DOCUMENT_SEND_API1. I noticed that when i specify the body type of the message as 'RAW' I get to see the pdf attachments however when i switch it to 'HTM' I loose the attachment in the email generated. Can anyone please help me in solving this problem. Thanks!

      ld_email                 = p_email. "All email IDs
      ld_mtitle                 = 'Bank Statement'.
      ld_format                = 'PDF'. "Attachment Format
      ld_attdescription      = 'Statement'.
      ld_attfilename          = p_filename. "Name of file
      ld_sender_address      = p_sender_address. "Sender mail address
      ld_sender_address_type = p_sender_addres_type. "INT - Internet
    * Fill the document data.
      w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle . "Description
      w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle. "Description
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    * Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'HTM'. " THis is for BODY of mail RAW'.
      APPEND t_packing_list.
    * Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    * Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    * Populate zerror return code
      ld_error = sy-subrc.

  • Send email in HTML format with attachment.

    I want to send out email in HTML fromat and attach a file to it. I know how to send HTML email but I cant attach a file to it.
    Can anybody help me with that?

    What kind of attachment?
    1) A file not related to the HTML
    or 2) a file used by the HTML (i.e. a GIF)?
    If 1) see here http://developer.java.sun.com/developer/onlineTraining/JavaMail/contents.html#SendingAttachments
    If 2) see here http://forum.java.sun.com/thread.jsp?forum=43&thread=242791
    (make sure you read all the thread as inline attachments are mentioned at the end)
    SH

  • Sending email with HTML report through a button

    Hi,
    I've noticed in APEX 4 there is a default option (through Action Menu -> Download Formats: email) to send an email with report in HTML format...
    may I know how to accomplish it using a Button... seems like APEX is using javascript:gReport.email.show(); function to accomplish it but I don't know how to implement it...
    Please advice
    Thanks in advance

    qwe12654 wrote:
    GokhanAtil,
    I've posted a sample on APEX.ORACLE.COM... LOGIN DETAILS ARE SAME AS ABOVE...
    ON the page now I have both the SQL based report and interactive report...
    On the top right you may see 2 icons.. one for downloading report in PDF (using SQL Report as the source) and the second for sending email (using interactive report, similar logic as what you've recommended)...
    Is there a way I may be able to send report via email, using SQL report as the source (rather than interactive report)...?
    You can always use APEX_MAIL to send emails.
    http://download.oracle.com/docs/cd/E10513_01/doc/apirefs.310/e12855/apex_mail.htm
    or the alternative option would be:
    to convert all my SQL reports into interactive, would require a bit of efforts (I'll go with it if the above option is not available)... but would need to know how to download INTERACTIVE reports in PDF, excel and CSV formats using a button ... similar logic to what you've done for sending emails
    Thanks again for all your assistanceIt's very easy to make buttons for downloading the interactive reports in HTML, CSV or PDF.
    I have created a PDF button and put the link:
    http://apex.oracle.com/pls/apex/f?p=40418:11:1316531694094700:PDF
    "1316531694094700" is the value of p_instance. You can find it from HTML codes of your page:
    <input type="hidden" name="p_instance" value="1316531694094700" id="pInstance">
    You can change PDF to CSV or HTMLD (so your visitor download the report in CSV or HTML)
    Best Regards,
    Gokhan
    If this question is answered, please mark appropriate posts as correct/helpful and the thread as closed. Thanks

  • Send email with html and images over Sockets

    Hi! I'm sending email messages through sockets with html. So far is working great. But now, I need to include images in the html code, like a web page. I don't have any idea on how to do this. Sending image apart from the html code is not big deal, but how to put it in the code. I mean how to make this html code, work:
    <table border="0">
         <tr>
              <td>Image in code</td>
         </tr>
         <tr>
              <img src="what to put here"/>
         </tr>
    </table>This is the code that I'm using to send the html mail:
    StringBuffer retBuff = new StringBuffer();
              //BufferedReader msg;
              //msg = new BufferedReader(msgFileReader);
              smtpPipe = new Socket(mailHost, SMTP_PORT);
              smtpPipe.setSoTimeout(120000);
              if (smtpPipe == null) {
                   return retBuff;
              inn = smtpPipe.getInputStream();
              outt = smtpPipe.getOutputStream();
              in = new BufferedReader(new InputStreamReader(inn));
              out = new PrintWriter(new OutputStreamWriter(outt), true);
              if (inn == null || outt == null) {
                   retBuff.append("Failed to open streams to socket.");
                   return retBuff;
              String initialID = in.readLine();
              retBuff.append(initialID);
              retBuff.append("HELO " + localhost.getHostName());
              out.println("HELO " + localhost.getHostName());
              String welcome = in.readLine();
              retBuff.append(welcome);
              retBuff.append("MAIL From:<" + from + ">");
              out.println("MAIL From:<" + from + ">");
              String senderOK = in.readLine();
              retBuff.append(senderOK);
              for (int i = 0; i < to.length; i++) {
                   retBuff.append("RCPT TO:<" + to[i] + ">");
                   out.println("RCPT TO:<" + to[i] + ">");
                   String recipientOK = in.readLine();
                   retBuff.append(recipientOK);
              retBuff.append("DATA");
              out.println("DATA");
              out.println("From: Steren <" + from + ">");
              out.println("Subject: " + subject);
              out.println("Mime-Version: 1.0;");
              out.println("Content-Type: text/html; charset=\"ISO-8859-1\";");
              //out.println("Content-Type: multipart/mixed; charset=\"ISO-8859-1\";");
              //out.println("Content-Transfer-Encoding: 7bit;");
              //String line;
              //while ((line = msg.readLine()) != null) {
              //     out.println(line);
              out.println(msg);
              retBuff.append(".");
              out.println(".");
              String acceptedOK = in.readLine();
              retBuff.append(acceptedOK);
              retBuff.append("QUIT");
              out.println("QUIT");
              return retBuff;

    Throw all this away and use one of the numerous existing Java mail packages, such as javax.mail for a start.

  • Send email with excel attachment in outlook structure - SAP 6.0

    Hello experts..
    I need send a email with a excel attachment and use the signature in outlook to send.
    The attachment will be create in the process of send email program.
    Is it possible?
    How can I created and attach in the same process?
    How can I use the outlook strutucture to send a email?

    I  resolved my own problem using the BCS_EXAMPLE_7 program as sample.

  • Z10 can't send email with ActiveSync from work Outlook webmail

    First off, love my Z10. It was able to connect to my work's Outlook webmail with no problem. I am able to get calendar and work emails.
    HOWEVER, I can't seem to be able to send email through my work account. When sending an email, I keep getting this red wrong way icon with the message:
    Message Status: Acknowledgement for send was not received from Server.
    What's wrong?
    I checked through my Outlook web account and it shows my phone within Mobile Phone Details:
    Access state: Access Granted
    Policy applied: Default - Applied in full
    ActiveSync version: 14.0
    Is there something I need to ask my IT staff for?
    Thanks.

    DueNorth wrote:
    First off, love my Z10. It was able to connect to my work's Outlook webmail with no problem. I am able to get calendar and work emails.
    HOWEVER, I can't seem to be able to send email through my work account. When sending an email, I keep getting this red wrong way icon with the message:
    Message Status: Acknowledgement for send was not received from Server.
    What's wrong?
    I checked through my Outlook web account and it shows my phone within Mobile Phone Details:
    Access state: Access Granted
    Policy applied: Default - Applied in full
    ActiveSync version: 14.0
    Is there something I need to ask my IT staff for?
    Thanks.
    It appears as if your email is running on Exchange 2010, and if so then you can troubleshoot this issue yourself to see if your phone is even talking to your ActiveSync server when it is trying to send the emails. If something doesn't jump out at you during this process, this information should help your IT folks in troubleshooting the effort.
    http://blogs.msdn.com/b/mstehle/archive/2013/04/29/howto-visual-guide-to-turn-on-exchange-activesync...
    You can also test the full functionality of ActiveSync on your account by using Microsoft's following testing tool, which should point out any major issues:
    https://www.testexchangeconnectivity.com/
    In regards to your question about what to ask your IT staff for, as an Exchange engineer myself I don't think there is anything on the server side that would let you connect and download email but not send it. So I would want to see the logs mentioned above to see what was going on with the device to server connectivity, in conjunction to the error message you already grabbed.
    There are some random "fixes" on the Internet such as this one which would be a server side configuration change, but again the more information you can supply your IT folks the better:
    http://forums.crackberry.com/blackberry-10-os-f269/bb10-exchange-activesync-issue-775934/

  • Sending emails with HTML or not?

    I am developing an application which will send 1000's of emails and I'm debating on whether or not to send html in the email. I have two questions:
    1. Do most email clients support html? Most of the recipients of the emails will be AOL, hotmail/msn, or yahoo clients. Are there any stats on how many people are running clients that don't support html?
    2. The emails I send require an embedded image. Can I send an email with an image and it not be a html email? If so, how? A multipart email? If anybody has an example that would be great!
    I'd prefer to not use HTML if possible.
    Thanks,
    JEB

    Here is a simplified version of the code. I've left out simple variable declarations, methods, and try-catch blocks but they are obivious...
            // AQUIRE THE JAVAMAIL SESSION OBJECT
            Properties props = new Properties();
            props.put("mail.smtp.host", smtpHost);
            Session session = Session.getInstance(props, null);
            // PREPARE THE MULTIPART MESSAGE
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from, personal));
            if (bcc != null)
                message.setRecipient(Message.RecipientType.BCC, new InternetAddress(bcc));
            message.setSubject(subject);
            MimeMultipart multipart = new MimeMultipart("alternative");
            BodyPart bodyPartText = new MimeBodyPart();
            BodyPart bodyPartHtml = new MimeBodyPart();
            BodyPart bodyPartImage = new MimeBodyPart();
            bodyPartImage.setDisposition(Part.INLINE);
            FileDataSource fds = new FileDataSource(photo);
            bodyPartImage.setFileName(fds.getName());
            bodyPartImage.setDataHandler(new DataHandler(fds));
            bodyPartImage.setHeader("Content-ID", "23abc@pc27");
            message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
            // THESE METHODS JUST RETURN TEXT OR HTML, RESPECTIVELY
            String htmlContent = createHtmlContent();
            String textContent = createTextContent();
            // SEND A HTML AND TEXT ALTERNATIVE EMAIL FOR THOSE WHO DON'T SUPPORT HTML
            bodyPartText.setContent(textContent, "text/plain");
            bodyPartHtml.setContent(htmlContent, "text/html");
            multipart.addBodyPart(bodyPartHtml ,0);
            multipart.addBodyPart(bodyPartImage, 1);
            multipart.addBodyPart(bodyPartText, 2);
            message.setContent(multipart);
            // SEND THE MAIL MESSAGE
            Transport.send(message);Hope this helps,
    JEB

Maybe you are looking for

  • HELP I deleted the mail and address book application, Is there a free DL???

    This used to be my mom's macbook but she gave it to me, at first her old mail account kept popping up in random occasions and couldn't figure out how to change the mail account to mine so I deleted it altogether permanently. Now it would be more conv

  • Probelm in standard tcode F150.

    Hai Gurus, While executing F150 for one company code say '1000'  for customer selection 10000 to 99999 we are getting o/p for customers in between 10000 to 99999 only. Where as for company code say '2000' we are getting A12500, A225000 (A series cust

  • Exception while performing Target Reconciliation

    My target is a CSV file which contains fields for empid (mapped as key field),firstname,lastname,emailid and status (mapped to OIM_OBJECT_STATUS) I can see the reconciliation data in Reconciliation event window in Design console but I am getting the

  • SM 59

    Hi I have to configure ALE for Inbound. Do i need to config. SM59 (RFC destination for Inbound). cos i am receving not sending.? Aryan

  • Find out previous Monday based on 0CALDAY

    Hi Gurus, I want a way to return the date of a pervious Monday regardless of the run day of the query. I have 0CALDAY field in query. How to do it please advice ? Thanks Liza