0 Replies - 526 Views - Last Post: 30 March 2011 - 11:37 AM Rate Topic: -----

#1 MeanArrow321  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-March 11

Save Message To Folder And Delete Deleted Items

Posted 30 March 2011 - 11:37 AM


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)
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
Call EmptyDeletedEmailFolder

End Sub]

I know that the GetSubFolderSize function works. I know that EmptyDeletedEmailFoler works.


This post has been edited by modi123_1: 30 March 2011 - 11:43 AM
Reason for edit:: please use code tags

Is This A Good Question/Topic? 0
  • +

Page 1 of 1