I am writing code to redirect mails from perticular EmailAddress.
For that i am giving user a form in which all the folders in outlook will be listed.
I am not getting the code to do this.
I can do this if i want to list folders from perticular folder like inbox by this :
Code:
Set myOlApp = CreateObject("Outlook.Application")
Set name = myOlApp.GetNamespace("MAPI")
Set fldFolder = name.Folders("olinbox")
'For Each prfolder In fldFolder
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Call GetFolderInfo(fldFolder)
GetFolderInfo is listing folders in fldfolder.
But i want to check for all folders in outlook.(like folders in outbox, inbox....)
Hi v_gyku,
It is me again So check out the attached code. It's a very usefull application and all my coleagues thanked me three times for creating this It is saving all attachments from all e-mails in selected directory. It creates a directory structure on the disk exactly like the one in your e-mail account. Also check out the filters
Tell me you opinion about it
You liked it? Please show your gratitude and rate it!
Private Sub CommandButton1_Click()
Dim NS As NameSpace
Set NS = Application.GetNamespace("MAPI")
listSubFolders NS.Folders(1)
End Sub
Private Sub listSubFolders(f As MAPIFolder, Optional i As Integer)
Dim x As MAPIFolder
For Each x In f.Folders
' Optional test for email type folders only
' If x.DefaultItemType = olMailItem Then
listFolders.AddItem x.EntryID
listFolders.Column(1, listFolders.ListCount - 1) = String(i, "-") & x.Name
If x.Folders.count > 0 Then listSubFolders x, i + 1
' End If
Next
End Sub
I have this code , but its giving me error on this lin :
Hi v_gyku,
It is me again So check out the attached code. It's a very usefull application and all my coleagues thanked me three times for creating this It is saving all attachments from all e-mails in selected directory. It creates a directory structure on the disk exactly like the one in your e-mail account. Also check out the filters
Tell me you opinion about it
If i select a folder which is not user cretaed then my code works fine.
But if try to route a message to a user created folder then it fails.
gives error: The operation failed. Object could not be found.
Code:
final1 = txtBrowse1.Text
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myOlApp = CreateObject("Outlook.Application")
Set fldFolder1 = myNameSpace.Folders(1)
Set myInbox = myNameSpace.Folders(1)
If final1 = "" Then
txtBrowse1.SetFocus
Else
Dim eidctr, post As Integer
eidctr = eid1.Count
post = 1
While eidctr > 0
MsgBox (fldFolder1.Folders.Item(eid1.Item(post)))
Set myDestFolder = fldFolder1.Folders.Item(eid1.Item(post))
eidctr = eidctr - 1
post = post + 1
Wend
End If
I am taking entry id of each folder in eid. iTs a collection.
I am listing all folders in outlook.
User will select any folder from a listbox.
User will select an email id from another listbox.
When he clicks on command button all the messages from selected email id will be shifted to selected folder.
If i am selecting a folder like inbox, outbox,drafts, junk email....(which r not user cretaed.) then my code is working fine.
But if i select user selected folder it gives me error: The operation failed. Object could not be found.
I Know all of these stuff.but not in VB in VC++ i can do.So if you wann idea how to do.i can tell .How to implement it's upto you.So exactly what the question and what is the issue here Please let me know.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.