Simple EventSink Copyrecord won't work!!! Help!!!
Exchange Server Forum Index Exchange Server
Discussion forums for Microsoft Exchange Server users.
Microsoft Outlook
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web ExchangeServerHelp.com
Simple EventSink Copyrecord won't work!!! Help!!!

 
Post new topic   Reply to topic    Exchange Server Forum Index -> Development
Author Message
Brett
Guest





Posted: Thu Nov 24, 2005 1:59 am    Post subject: Simple EventSink Copyrecord won't work!!! Help!!! Reply with 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!!!!

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!!!

Back to top
Glen Scales [MVP]
Guest





Posted: Thu Nov 24, 2005 1:59 am    Post subject: Re: Simple EventSink Copyrecord won't work!!! Help!!! Reply with quote

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!!!
Back to top
Brett
Guest





Posted: Fri Nov 25, 2005 5:58 pm    Post subject: Re: Simple EventSink Copyrecord won't work!!! Help!!! Reply with quote

Aaargh!!! I can't believe I missed that!!

Thanks much!!!

Back to top
 
Post new topic   Reply to topic    Exchange Server Forum Index -> Development All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server Dedicated Servers
Contact Us
New Topics Powered by phpBB