Wow lot of code
Thank you Jaffer,
But i think I don't need that much code.
My requirement is very simple.
Now I made a string from a mail with the required text in it
This string has to be copied in to a text file (bY opening a new one)
and save the text file in to the required path and close it
Ok LakshmanaRavula
tell me,
will there be only 1 email?
Will this/these emails always have 1 thing in common, like the same subject, OR certain words in the body?
jaffer
0
Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
I'm preparing a macro which will fire when ever a new mail arrives and process the mail. as a part of it I need to store certain data in to a text file
Yes as i said to you in my earlier posting "GG" and "TTT" are common words in the body
I need the text between these two strings which will be changing from amil to mail
I need to copy the contents starts from specified string "GG" (including "GG") and ends before specified string "TTT" (Excluding "TTT")
Thank You
'Function savePartOfMail(theBody, startWith, endWith, saveToFile) As String
Dim strMsg As String
Dim startAt As Long
Dim endAt As Long
Dim fso As Object, MyFile As Object
Set fso = CreateObject("Scripting.FileSystemObject")
savePartOfMail = ""
startAt = InStr(1, theBody, startWith, vbTextCompare)
If startAt = 0 Then Exit Function
endAt = InStr(1, theBody, endWith, vbTextCompare)
If endAt = 0 Then Exit Function
Set MyFile = fso.OpenTextFile(saveToFile, ForWriting, True)
savePartOfMail = Mid(theBody, startAt, endAt)
MyFile.Write savePartOfMail
MyFile.Close
Set MyFile = Nothing
Set fso = Nothing
End Function
call it with
Dim stout as string
dim saveInFile as string
saveInFile ="c:\myPatialMail.txt"
stout = savePartOfMail(theBody, "GG", "TTT", saveInFile)
I output stout just if you would need it in the rest of the code
Stefr
0
LakshmanaRavulaAuthor Commented:
Hi stefri glad to see you again
I'm facing problem to call a function from the macro which i'M preparing
There is a compile error in the function
Variable not defined
and highlighting ForWriting
in " Set MyFile = fso.OpenTextFile(saveToFile, ForWriting, True)"
Go to this link, I have done this in Access, but you can remove the Form and Table stuff from it,
It will help you in what you want,
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20940488.html#10735881
Hope this helps
jaffer