I am new to Outlook vba programming. What I want is to save a mail to a specific folder upon its reception in the mailbox AFTER veryfying that the predefine mailbox capacity is almost reached . After, i would like to delete the item and then delete all items in the deleted folder. I have tried something but it doesn't work and it doesn't show errors. It seems like something is missing. I'm sorry, i have actually gathered different code i found to make one... I need some help here...
[
Private Sub objInbox_ItemAdd(ByVal item As Object)
Dim lFolderSize As Long
Dim objSubFolder As MAPIFolder
Dim test As String
Dim FNme As String
Dim DirName As String
Dim iCount As Integer
Dim itm As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objOutlookToday = objInbox.Parent
For Each objSubFolder In objOutlookToday.Folders
lFolderSize = lFolderSize + GetSubFolderSize(objSubFolder)
Next
MsgBox "Total Size = " & lFolderSize
If lFolderSize > 50000000 Then
DirName = "C:\Documents and Settings\name\Desktop\folder\"
Set Folder = Outlook.ActiveExplorer.CurrentFolder 'selects the active mailbox
test = itm.Subject
FNme = DirName & test & ".msg"
item.SaveAs FNme, olMSG
item.Delete
Call EmptyDeletedEmailFolder
End Sub]
I know that the GetSubFolderSize function works. I know that EmptyDeletedEmailFoler works.
thanks
MeanArrow
This post has been edited by modi123_1: 30 March 2011 - 11:43 AM
Reason for edit:: please use code tags

New Topic/Question
Reply



MultiQuote


|