PDA

View Full Version : Read E:Mail attachment for Input



vodkasoda
05-26-2009, 03:02 AM
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 :

For EMailNo = NoOfEMails To 1 Step -1
Set EMail = SubFolder1.Items(EMailNo)
KIKcount = 0
TXTcount = 0
MySkip = False
For Each Atmt In EMail.Attachments


I read the original file as follows :

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


and then I try to read the new file as follows :

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


However, the line ... Open Atmt For Input As #MyFileNum ... 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 ?

Oorang
05-29-2009, 11:55 PM
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.