Keeping VBA generated emails out of OutBox

Joined
Apr 18, 2012
Messages
1
Reaction score
0
Greetings!

I have an Access 2010 database that automates the creation and sending of potentialing up 60 emails with attachments.

Problem is a VERY limited amount of mailobox space and this process will freeze Outlook due to Sent Items filling up. I thought had solved this problem by setting the mail items SaveSentMessageFolder to a Personal Folder. This part works beautifully but now all these emails, even though they are sent and moved to the Personal Folder, stay in the Outbox eating up MailBox space causing Outlook to freeze.

I have tried using DeleteAfterSubmit = true... no difference. Called the Send/Receive function or emptying the Outbox after so many emails are created but this just puts them into Deleted Items and these both SLOW down an already lengthy process.

How can I send these emails while saving them in a Personal Folder AND keeping them from accumulating in the OutBox?

Here is the code I've been testing with. Thanks for y'alls assistance!

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim NmSpace As NameSpace
Dim pstFolder As Outlook.MAPIFolder
Dim x As Integer

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
Set NmSpace = objOutlook.GetNamespace("MAPI")
Set pstFolder = NmSpace.Folders("Personal Folders").Folders("Inbox")
For x = 1 To 20
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipients to the message.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the message and Attach file.
.Attachments.Add ("c:\Test.pdf")
.Subject = "Test Email " & x
.Body = "This is a test"
.Importance = olImportanceHigh
Set .SaveSentMessageFolder = pstFolder
.Send
End With

Set objOutlookMsg = Nothing

Next

Set objOutlook = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top