Consulting

Results 1 to 1 of 1

Thread: Need HTML - VBA code for sending email with multiple lines in body

  1. #1

    Post Need HTML - VBA code for sending email with multiple lines in body

    Hello all,

    I am trying to create a macro in an excel, where i click on a button and it sends out email.

    I've following requirement.

    1) I want to have at least 30 ppl in TO,cc and Bcc filed
    2) the email body should be of multiple lines with html tag support so i can bold, underline text where ever i required.

    I am using following VBA code with .HTMLBoday as email body but in this code, i am not able to add more than one line in the email body.

    Sub Send_Email_Using_VBA()
        Dim Email_Subject, Email_Send_From, Email_Send_To, _
        Email_Cc, Email_Bcc, Email_Body As String
        Dim Mail_Object, Mail_Single As Variant
        Email_Subject = "Trying to send email using VBA with HTML tags"
        Email_Send_From = "abc@xyz.com"
        Email_Send_To = "abc@xyz.com"
        Email_Body = "I have successfully sent an <I> e-mail </I> using <B> VBA </B> !!!!"
        On Error GoTo debugs
        Set Mail_Object = CreateObject("Outlook.Application")
        Set Mail_Single = Mail_Object.CreateItem(0)
        With Mail_Single
            .Subject = Email_Subject
            .To = Email_Send_To
            .cc = Email_Cc
            .BCC = Email_Bcc
            .HTMLBody = Email_Body
            .send
        End With
        debugs:
        If Err.Description <> "" Then MsgBox Err.Description
    End Sub


    Please help by providing the new code.

    Thanks in advance.
    Last edited by Aussiebear; 01-18-2025 at 04:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •