Hi,
I have a code to create new emails and send through VBA. PLease see below.
However, I am new to VBA and have searched everywhere for a code that would help in replying to emails through VBA.
I have many emails and my reply is more or less standard. Is there a code, where i can 1) select the email that i want to reply, 2) pick up the body of the email from my excel file (designated Range/cell) and 3) send out the email to the recipient?
Your help would be much appreciated.
Sub Test1()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "C").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = Cells(cell.Row, "D").Value
.Body = Cells(cell.Row, "E").Value
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'Or use Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Bookmarks