Outlook Related Help
1. all mails received in outlook to a particular folder e.g. c:\Inmail
2. The mail which is saved as file in a folder should have name
equal to teh email address of sender. e.g if the mail is recd from abc@rediffmail.com, then the contents
of the file shd be saved in the that file with teh filename
abc@rediffmail.com
Please help me I have tried by writing following code WHICH SATISHFIES first condn but second not
-------------
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
End Sub
Private Sub Application_NewMail()
Dim strExtFldName As String, filename As String
Dim objIntFld, fldObj, objFile, objItem, objTextStream
Dim myNameSpace As NameSpace
Dim latestMessageNo As Integer
strExtFldName = "C:\\Inmail"
Set myNameSpace = ThisOutlookSession.GetNamespace("MAPI")
Set objIntFld = myNameSpace.GetDefaultFolder(olFolderInbox)
latestMessageNo = objIntFld.Items.Count
Set fldObj = CreateObject("Scripting.FileSystemObject")
If Not fldObj.folderexists(strExtFldName) Then
fldObj.createfolder strExtFldName
End If
Set objItem = objIntFld.Items(latestMessageNo)
filename = strExtFldName & "\" & objItem.SenderName & ".txt"
fldObj.CreateTextFile filename
Set objFile = fldObj.GetFile(filename)
Set objTextStream = objFile.OpenAsTextStream(2, -2)
objTextStream.Write objIntFld.Items(latestMessageNo).Body
End Sub

