Results 1 to 3 of 3

Thread: I need help to edit my vba code for the wrapped text

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Sep 2023
    Posts
    3
    Location

    I need help to edit my vba code for the wrapped text

    Hi, I am using html.body for my email body to have the signature in the email. However, my text all become one line. can anyone help to edit the coding? Appreciate your help.


    Sub Send_Mails()
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("Bulk Email")
    Dim i As Integer
    Dim OA As Object
    Dim msg As Object
    Set OA = CreateObject("outlook.application")
    Dim last_row As Integer
    Dim Signature As String
    Dim bodyMain As String
    last_row = sh.Range("D" & Application.Rows.Count).End(xlUp).Row
    For i = 6 To last_row
        If UCase(sh.Range("A" & i).Value) <> "YES" Then
            Set msg = OA.createitem(0)
            If sh.Range("C" & i).Value <> "" Then msg.SentOnBehalfOfName = sh.Range("C" & i).Value
            Set msg.SendUsingAccount = OA.Session.Accounts.Item(1)
            msg.display
            Signature = msg.HTMLBody
            msg.To = sh.Range("D" & i).Value
            msg.cc = sh.Range("E" & i).Value
            msg.Subject = sh.Range("F" & i).Value
            msg.body = sh.Range("G" & i).Value
            msg.HTMLBody = sh.Range("G" & i).Value & vbNewLine & Signature
            If sh.Range("H" & i).Value <> "" Then
                msg.attachments.Add sh.Range("H" & i).Value
            End If
            If sh.Range("I" & i).Value <> "" Then
                msg.attachments.Add sh.Range("I" & i).Value
            End If
            If sh.Range("J" & i).Value <> "" Then
                msg.attachments.Add sh.Range("J" & i).Value
            End If
            If sh.Range("K" & i).Value <> "" Then
                msg.attachments.Add sh.Range("K" & i).Value
            End If
            If sh.Range("A1").Value = 1 Then
                msg.send
            Else
                msg.display
            End If
            sh.Range("B" & i).Value = "Done"
        End If
    Next i
    MsgBox "Process Completed!!!", vbInformation
    End Sub
    Attached Files Attached Files
    Last edited by Aussiebear; 09-13-2023 at 04:28 PM. Reason: Added code tags to supplied code

Posting Permissions

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