Greetings:
Attached is the code I have to copy data from an active excel spreadsheet. When run it opens the new email, fill the TO, CC and Subject fields, also change the delivery delay info. But the data in the email body only shows if I hit CTRL V.
Any assistance its kindly welcome.
Private Sub CommandButton1_Click()
Dim a As Integer
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngCC As Range
Dim rngSubject As Range
Dim rngBody As Range
Dim rngAttach As Range
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
a = ActiveCell.Row
With ActiveSheet
Set rngTo = Range("B3")
Set rngCC = Range("B5")
Set rngSubject = .Range("B12")
Set rngBody = .Range("A14:B32")
rngBody.Copy
End With
With objMail
.to = rngTo.Value
.CC = rngCC.Value
.Subject = rngSubject.Value
'SET DELAY DELIVERY DATE - Stay in the outbox untill this date and time
.DeferredDeliveryTime = "11/10/2022 11:00:00 AM"
rngBody.PasteSpecial
'Instead of .Display, you can use .Send to send the email or .Save to save a copy in the drafts folder
.Display
End With
Set objOutlook = Nothing
Set objMail = Nothing
Set rngTo = Nothing
Set rngCC = Nothing
Set rngSubject = Nothing
Set rngBody = Nothing
Set rngAttach = Nothing
End Sub
Bookmarks