Monday, June 30 2008: DeleteAfterSubmit
I have this little report mailer that runs two times a day. As the inherent superiority of this method of report delivery has become known throughout the TRC, the number of reports and recipients has mushroomed - resulting in my mailbox becoming full on the Exchange server due to the large number of messages accumulating due to this feature.
This single line of code has saved me so much asspain it is worth blogging about. If you set the DeleteAfterSubmit property to True, then after sending the mailitem, it will delete itself from the Sent Items folder and it will not clutter the Deleted Items folder either. Permanent deletion without any muss or fuss. I can hardly believe it. This is not like Microsoft.
This single line of code has saved me so much asspain it is worth blogging about. If you set the DeleteAfterSubmit property to True, then after sending the mailitem, it will delete itself from the Sent Items folder and it will not clutter the Deleted Items folder either. Permanent deletion without any muss or fuss. I can hardly believe it. This is not like Microsoft.
Set theMsg = ol.CreateItem(olMailItem)
' Clear any errors so you don't get a false alarm below
Err.Clear
' Use Outlook to compose and send the message
With theMsg
.Attachments.Add fso.BuildPath(WorkArea, Doc)
.Body = EmailBodyOfMessage
.To = ToEmail
.Subject = EmailSubject
' This will clean up the crap, yay!
.DeleteAfterSubmit = True
.Send
End With
Set theMsg = Nothing