-
Read E:Mail attachment for Input
I am reading an E:Mail with an attachment of .KIK (it's basically a text file) and will be saving it, replacing the existing file of the same name.
However, I'd like to add some validation to make sure that the file I am receiving is the correct one, and this is done by checking a line within the file that starts "SessionNo=".
The controlling loop is as follows :
[VBA]For EMailNo = NoOfEMails To 1 Step -1
Set EMail = SubFolder1.Items(EMailNo)
KIKcount = 0
TXTcount = 0
MySkip = False
For Each Atmt In EMail.Attachments
[/VBA]
I read the original file as follows :
[VBA] MyFileNum = FreeFile()
Open KAfullpath For Input As #MyFileNum
Do While Not EOF(MyFileNum)
Input #MyFileNum, MyKIKdata
If Left(MyKIKdata, 10) = "SessionNo=" Then
MyKIKold = Right(MyKIKdata, (Len(MyKIKdata) - 10))
Exit Do
End If
Loop
Close #MyFileNum
[/VBA]
and then I try to read the new file as follows :
[VBA] MyFileNum = FreeFile()
Open Atmt For Input As #MyFileNum
Do While Not EOF(MyFileNum)
Input #MyFileNum, MyKIKdata
If Left(MyKIKdata, 10) = "SessionNo=" Then
MyKIKnew = Right(MyKIKdata, (Len(MyKIKdata) - 10))
Exit Do
End If
Loop
Close #MyFileNum
[/VBA]
However, the line ... [VBA]Open Atmt For Input As #MyFileNum[/VBA] ... gives me an error message of Run Time Error '53': File Not Found ...
I guess that I should be using some other pointer other than Atmt, but what ?!?! Can I do what I want or will I have to save the attachment and access it that way ?
-
First, I want to compliment you on one of the most well constructed posts I have read in a very long time. Secondly, the properties you want are Atmt.FileName and Atmt.PathName. I am not where I can test it, but I am fairly certain Atmt.PathName should include the folder and the filename, but if not, just concatenate them.
Cordially,
Aaron
Keep Our Board Clean! - Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
- Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules