PDA

View Full Version : Forward latest sent items and Copy



Subir
01-12-2014, 11:21 PM
Is there a way to forward the latest sent items and copy the whole email.

westconn1
01-13-2014, 01:48 AM
probably, but i am not sure that i understand what you want to do

Subir
01-14-2014, 10:10 PM
suppose i am sending an email from outlook, after sending what i want to do is the email which has been sent recently will be forwarded automatically and the entire email body will be copied in excel sheet by vba.

westconn1
01-17-2014, 04:53 AM
you can try like

Set apps = Session.GetDefaultFolder(olFolderSentMail).Items
somedate = "09/05/2013"
Set recent = apps.Restrict("[SentOn] > '" & somedate & "'")
For Each mi In recent.Items
mi.To = "someone@somewhere.com"
mi.Send
Body = mi.Body
'insert body to excel workbook
Next
you can change somedate to whatever value you consider to be recent, maybe like now - 2 hours
you could also use the item sent event to do automatically


Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Set mybcc = item.Recipients.Add = "someone@somewhere.com"
mybcc.Type olBCC
' insert item.body to excel
end sub