bradh_nz
01-13-2010, 09:23 PM
I have the below code that works fine, it is running of a rule and will save the excel attachment to a directory. However I cannot get the move message after this has hapened to work, esentially this line
objMail.Move objInboxFolder.Folders("NZRC Interrupible").Folders("2.Processed")
It needs to move it to a folder within a folder.
Thanks
Sub SaveToFolder(MyMail As MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim objAtt As Outlook.Attachment
Dim c As Integer
Set myDestFolder = myInbox.Folders("Reference")
'Place path to sav to on next line.
Const save_path As String = "G:\Gas\Trading Daily Gas Tools\Interruptible User Contract\"
strID = MyMail.EntryID
Set objNS = Application.GetNamespace("MAPI")
Set objMail = objNS.GetItemFromID(strID)
If objMail.Attachments.Count > 0 Then
For c = 1 To objMail.Attachments.Count
Set objAtt = objMail.Attachments(c)
save_name = Left(objAtt.FileName, Len(objAtt.FileName) - 4)
'save_name = save_name & Format(objMail.ReceivedTime, "_mm-dd-yyyy_hhmm")
save_name = save_name & Right(objAtt.FileName, 4)
objAtt.SaveAsFile save_path & save_name
Next
'objMail.Move objInboxFolder.Folders("NZRC Interrupible").Folders("2.Processed")
End If
Set objAtt = Nothing
Set ApExcel = Nothing
Set objMail = Nothing
Set objNS = Nothing
End Sub
objMail.Move objInboxFolder.Folders("NZRC Interrupible").Folders("2.Processed")
It needs to move it to a folder within a folder.
Thanks
Sub SaveToFolder(MyMail As MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim objAtt As Outlook.Attachment
Dim c As Integer
Set myDestFolder = myInbox.Folders("Reference")
'Place path to sav to on next line.
Const save_path As String = "G:\Gas\Trading Daily Gas Tools\Interruptible User Contract\"
strID = MyMail.EntryID
Set objNS = Application.GetNamespace("MAPI")
Set objMail = objNS.GetItemFromID(strID)
If objMail.Attachments.Count > 0 Then
For c = 1 To objMail.Attachments.Count
Set objAtt = objMail.Attachments(c)
save_name = Left(objAtt.FileName, Len(objAtt.FileName) - 4)
'save_name = save_name & Format(objMail.ReceivedTime, "_mm-dd-yyyy_hhmm")
save_name = save_name & Right(objAtt.FileName, 4)
objAtt.SaveAsFile save_path & save_name
Next
'objMail.Move objInboxFolder.Folders("NZRC Interrupible").Folders("2.Processed")
End If
Set objAtt = Nothing
Set ApExcel = Nothing
Set objMail = Nothing
Set objNS = Nothing
End Sub