How to align center sent email from excel VBA

2019-09-10 04:58发布

I want to center-align an email I sent from excel range selection using VBA but I'm not sure where to put it in the code. Someone suggested me to just add a column to my range. Is there anyway I can put the code in VBA. Btw, I'm really new at this language (like just an hour ago). Here's my code, I got it from a microsoft page:

Sub Send_Range()

ActiveSheet.Range("D4:L23").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
  .Item.To = "ABZ@123.com"
  .Item.Subject = "REMINDER: HELLO TEST" & " " & Format(Now, "mmmm yyyy")
  .Item.Send
End With
End Sub

Finished Product: enter image description here

1条回答
何必那么认真
2楼-- · 2019-09-10 05:21

A simple version of what Scott is referring to would be

Sub test()

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

sEmail = "Please check your status on " & Activesheet.Range("A1").value
'ie..Range("A1").value has the formula "=today()"

With OutMail
        .to = ""
        .CC = ""
        .BCC = ""
        '.FROM = ""
        .Subject = ""
        .htmlBody = "<p align=""center"">" & sEmail & "</p>"
        .Send
End With

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
查看更多
登录 后发表回答