PDA

View Full Version : Monitoring Emails Sent From VBA



hk129
07-14-2015, 08:48 AM
Hi everyone,

I am trying to create a program in excel to send out emails (the emails contain data from the cells). Here is a sample of my code (not completed):

Sub Send_Mail(ActiveCell)


Dim OutApp As Object
Dim OutMail As Object

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

On Error Resume Next
With OutMail

.To = ActiveCell.Offset(0, -2).Text
On Error GoTo 0
.CC = ""
.BCC = ""
.Subject = "AUTOMATED MESSAGE" + ActiveCell.Offset(0, -4).Text
.Body = "This is a test: " + ActiveCell.Offset(0, -4).Text
.Send
ActiveCell.Offset(0, 1).Value = "YES"

On Error GoTo 0

End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub


I can successfully send out my emails but I have no way of keeping track of the emails that got send. When I open outlook, there is nothing in my sent folder.

Can anyone help me out?
Thank you in advance.

snb
07-14-2015, 09:34 AM
This suffices:


Sub M_Send_Mail()
With CreateObject("Outlook.Application").CreateItem(0)
.To = ActiveCell.Offset(, -2)
.Subject = "AUTOMATED MESSAGE" & ActiveCell.Offset(, -4)
.Body = "This is a test: " & ActiveCell.Offset(, -4)
.Send
End With
ActiveCell.Offset(, 1) = "YES"
End Sub

First you'll find these mails in PostOUT

hk129
07-14-2015, 10:34 AM
thanks!