Hi guys
I have been trying to copy a file to a shared mailbox with no luck. At the moment I am just trying to move 1 file to make sure it works but going forward it will be around 100 a week in different folders.
I get stuck at the copyfile part and it says:
Run-time error '-2147024809(80070057)';
Could not complete the operation. One or more parameter values are not valid
Been looking around google and searched forums but no luck,
Thanks
Ian
I have been trying to copy a file to a shared mailbox with no luck. At the moment I am just trying to move 1 file to make sure it works but going forward it will be around 100 a week in different folders.
I get stuck at the copyfile part and it says:
Run-time error '-2147024809(80070057)';
Could not complete the operation. One or more parameter values are not valid
Been looking around google and searched forums but no luck,
Thanks
Ian
Code:
Sub CopyFileToMailbox()
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objDummy As Outlook.MailItem
Dim objRecip As Outlook.Recipient
Dim strMsg As String
Dim strName As String
Dim strPath As String
On Error Resume Next
strPath = "f:/MyExcelDoc.xls"
' ### name of mailbox ###
strName = "~ CMC Telephony Support Team"
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objDummy = objApp.CreateItem(olMailItem)
Set objRecip = objDummy.Recipients.Add(strName)
objRecip.Resolve
If objRecip.Resolved Then
On Error Resume Next
Set objFolder = GetFolder("Mailbox - ~ CMC Telephony Support Team/Test")
objApp.CopyFile strPath, objFolder
Else
MsgBox "Could not find " & Chr(34) & strName & Chr(34), , _
"User not found"
End If
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objDummy = Nothing
Set objRecip = Nothing
End Sub