How to align center sent email from excel VBA

北城余情 提交于 2019-12-12 01:16:31

问题


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:


回答1:


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


来源:https://stackoverflow.com/questions/35993748/how-to-align-center-sent-email-from-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!