Brett
Guest
|
Posted:
Thu Nov 24, 2005 1:59 am Post subject:
Simple EventSink Copyrecord won't work!!! Help!!! |
|
|
I'm attempting to copy emails from one mailbox to another, using an
async onsave event script. It fires, but I'm getting an error "3732"
when I try to copy from one mailbox to another; Same Server, Same
Storage group. The com+ object is running using a Full Exchange Admin
(also domain admin), so I don't think it's rights.
It works perfect copying to another folder of the same mailbox, just
not to another mailbox!!!!
| Quote: | From a command line, when I do this:
dir //./backofficestorage/ourdomain/MBX/usernametocopyto/Inbox/Test/, I |
can see everything. The file I create is for debugging. That's how I
can see the error which occurs right after copyrecord.
What's wrong?
here's the code:
'*******************************************************************************************************
<SCRIPT Language=VBScript>
Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags)
On Error Resume Next
Dim objFSO, f1, iEventInfo, objRec, sFolder, sDestMailbox, sDisplay,
sURL
Dim Conn
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set f1 =
objFSO.CreateTextFile("D:\Scripts\EventSinks\General\evlog.log", True)
f1.writeline("Source Item: " & bstrURLItem & vbcrlf)
Set iEventInfo = pEventInfo
Set objRec = iEventInfo.EventRecord
f1.Writeline("Current Error: " & Err.Number & vbCrLf)
Err.Clear
sDestMailbox =
"file://./backofficestorage/ourdomain/MBX/usernametocopyto/Inbox/Test/"
sDisplay = CStr(objRec.Fields("DAV:displayname").Value)
f1.writeline("Destination: " & sDestMailbox & sDisplay & vbCrLf)
objRec.CopyRecord bstrURL, sDestMailbox & sDisplay, , , adCopyOverWrite
f1.Writeline("Current Error: " & Err.Number & vbCrLf)
Err.Clear
objRec.Close
Set objRec = Nothing
f1.Close
Set objFSO = Nothing
End Sub
</SCRIPT>
'*******************************************************************************************************
Any help would be greatly appreciated!!!
|
|
Glen Scales [MVP]
Guest
|
Posted:
Thu Nov 24, 2005 1:59 am Post subject:
Re: Simple EventSink Copyrecord won't work!!! Help!!! |
|
|
CopyRecord can only be used to copy objects within a mailbox it can't be
used to copy objects from one mailbox to another or from a mailbox to a
public folder see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_exch2k_copying_items.asp.
One work around for this is to get the RFC 822 stream of the message and
create a new item in the other mailbox using this stream. The drawback of
using this method is that you loose any Mapi properties that are attached to
the message (recieved time also get changed). Eg this is a sample of copying
a message including a manual copy of the RTF body.
set msgobj = createobject("CDO.Message")
set msgobj1 = createobject("CDO.Message")
set stm = CreateObject("ADODB.Stream")
msgobj.datasource.open
"file://./backofficestorage/youdomain.com/MBX/sourcembx/inbox/item.EML",,3
set stm = msgobj.getstream()
msgobj1.datasource.openobject stm, "_Stream"
rtfbody =
msgobj.fields("http://schemas.microsoft.com/mapi/proptag/x10090102")
msgobj1.fields("http://schemas.microsoft.com/mapi/proptag/x10090102") =
rtfbody
msgobj1.fields.update
msgobj1.datasource.savetocontainer
"file://./backofficestorage/managenet.com.au/MBX/targetmbs/inbox/",,3
Cheers
Glen
"Brett" <brett.mack@gmail.com> wrote in message
news:1132782031.846065.42840@g43g2000cwa.googlegroups.com...
| Quote: | I'm attempting to copy emails from one mailbox to another, using an
async onsave event script. It fires, but I'm getting an error "3732"
when I try to copy from one mailbox to another; Same Server, Same
Storage group. The com+ object is running using a Full Exchange Admin
(also domain admin), so I don't think it's rights.
It works perfect copying to another folder of the same mailbox, just
not to another mailbox!!!!
From a command line, when I do this:
dir //./backofficestorage/ourdomain/MBX/usernametocopyto/Inbox/Test/, I
can see everything. The file I create is for debugging. That's how I
can see the error which occurs right after copyrecord.
What's wrong?
here's the code:
'*******************************************************************************************************
SCRIPT Language=VBScript
Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags)
On Error Resume Next
Dim objFSO, f1, iEventInfo, objRec, sFolder, sDestMailbox, sDisplay,
sURL
Dim Conn
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set f1 =
objFSO.CreateTextFile("D:\Scripts\EventSinks\General\evlog.log", True)
f1.writeline("Source Item: " & bstrURLItem & vbcrlf)
Set iEventInfo = pEventInfo
Set objRec = iEventInfo.EventRecord
f1.Writeline("Current Error: " & Err.Number & vbCrLf)
Err.Clear
sDestMailbox =
"file://./backofficestorage/ourdomain/MBX/usernametocopyto/Inbox/Test/"
sDisplay = CStr(objRec.Fields("DAV:displayname").Value)
f1.writeline("Destination: " & sDestMailbox & sDisplay & vbCrLf)
objRec.CopyRecord bstrURL, sDestMailbox & sDisplay, , , adCopyOverWrite
f1.Writeline("Current Error: " & Err.Number & vbCrLf)
Err.Clear
objRec.Close
Set objRec = Nothing
f1.Close
Set objFSO = Nothing
End Sub
/SCRIPT
'*******************************************************************************************************
Any help would be greatly appreciated!!!
|
|
|