Sign in to follow this  
Followers 0
anixon

File Attributes

2 posts in this topic

The following code creates and writes records to a user created system file:

$DailyLog = $wPath & (@MON & StringRight(@YEAR, 2)) & "\Day\" & @MDAY & "\" & (@MDAY & @MON & StringRight(@YEAR, 2)) & $wFile
        ;//Change the Attribute to Read/Write
        If FileExists($DailyLog) Then FileSetAttrib($DailyLog, "-RS")
        ;//Open the File or Create a New File
        $DayFile = FileOpen($DailyLog, 9)
        ;//Write the Record
        FileWriteLine($DayFile, $wRecord)
        FileClose($DayFile)
        FileSetAttrib($DailyLog, "+RS")

This is the CDO code that deals with the attachment:

$oOutlook.AddAttachment($s_Attachment)

For some reason when you try and add a record to the file associated with the $s_Attachment the record to add simply will not be processed to the file until the $s_attachent path and file name is changed to another file in which case the previously emailed attachment is released and you are no longer able to write records to that file.

This code $s_Attachment = "" does not remedy the issue.

When you look at the file in Windows properties there is nothing to suggest that the attributes cause it to read only as it is listed as a RSA file exactly the same as one that has not been an attachment and you can write to.

I was thinking that the remedy might be to change the files attributes using the -RS then attaching it to the CDO message then after it has been sent changing the

attributes back to +RS or is this or is their a better solution

Assistance is always appreciated Ant...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The following code creates and writes records to a user created system file:

$DailyLog = $wPath & (@MON & StringRight(@YEAR, 2)) & "\Day\" & @MDAY & "\" & (@MDAY & @MON & StringRight(@YEAR, 2)) & $wFile
        ;//Change the Attribute to Read/Write
        If FileExists($DailyLog) Then FileSetAttrib($DailyLog, "-RS")
        ;//Open the File or Create a New File
        $DayFile = FileOpen($DailyLog, 9)
        ;//Write the Record
        FileWriteLine($DayFile, $wRecord)
        FileClose($DayFile)
        FileSetAttrib($DailyLog, "+RS")

This is the CDO code that deals with the attachment:

$oOutlook.AddAttachment($s_Attachment)

For some reason when you try and add a record to the file associated with the $s_Attachment the record to add simply will not be processed to the file until the $s_attachent path and file name is changed to another file in which case the previously emailed attachment is released and you are no longer able to write records to that file.

This code $s_Attachment = "" does not remedy the issue.

When you look at the file in Windows properties there is nothing to suggest that the attributes cause it to read only as it is listed as a RSA file exactly the same as one that has not been an attachment and you can write to.

I was thinking that the remedy might be to change the files attributes using the -RS then attaching it to the CDO message then after it has been sent changing the

attributes back to +RS or is this or is their a better solution

Assistance is always appreciated Ant...

I have done some more testing and it is not at attribute problem my guess is that the Outlook object still has control over the file so the question is how do you get Outlook to release the attached file after the email has been sent?

Depending on which transport is used to send the message the code for attaching the file can be either

With $oMessage

.Attachments.Add($s_AttachDummy)

EndWith

or

$oOutlook.AddAttachment($s_AttachDummy)

I have resolved this issue by simply copying the file and using the temp copy as the attachment.

Edited by anixon

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0