PROBLEM using event sink, cdo, saving message and attchments to disk

PROBLEM using event sink, cdo, saving message and attchments to disk

Post by Wim Mintien » Wed, 16 Jan 2002 23:34:20



Hi out there,

I am trying to save each message & there attachments to disk.

I created an event sink for this, the code looks like this:

Private Sub IExStoreAsyncEvents_OnSave(ByVal pEventInfo As
IExStoreEventInfo, ByVal bstrURLItem As String, ByVal lFlags As Long)

    Dim rec As New ADODB.Record
    Dim conn As New ADODB.Connection
    Dim msg As New CDO.Message
    Dim X As Integer
    Dim copiedmsg As New CDO.Message
    Dim strContentClass As String
    Dim strMessageBody As String

    conn.Provider = "Exoledb.datasource"

    conn.Open "file://./backofficestorage/ntdomain.test/Public
Folders/Archive/"

    Call EventLog("OnSave", bstrURLItem, IFlags, "Conn open")

    rec.Open bstrURLItem, conn

    Call EventLog("OnSave", bstrURLItem, IFlags, "rec open")

    msg.DataSource.Open bstrURLTem, conn, adModeReadWrite
    Call EventLog("OnSave", bstrURLItem, IFlags, "msg open")

    strMessageBody = msg.TextBody
    Call EventLog("OnSave", bstrURLItem, IFlags, strMessageBody)

    msg.GetStream.SaveToFile "c:\temp\msg.txt"

    rec.Close
    conn.Close
    Set rec = Nothing
    Set conn = Nothing

Exit Sub

Each time i try to open the message with the
msg.DataSource.Open bstrURLTem, conn, adModeReadWrite
i get an error:

Event Name:OnASyncSave
 URL of Source Item: file://./backofficestorage/ntdomain.test/Public
Folders/Archive/testing 123 part2.EML
 Flags (0x41): EVT_NEW_ITEM  EVT_INITNEW
 COMMENT:

when substitute the line with:

msg.DataSource.Open file://./backofficestorage/ntdomain.test/Public
Folders/Archive/testing 123 part2.EML, conn, adModeReadWrite

it works fine, how can i let it work with the bstrlURLItem variable as is
suppose to work...

PLEASE anyone HELP ME

Regards,
Wim Mintiens

 
 
 

PROBLEM using event sink, cdo, saving message and attchments to disk

Post by Wim Mintien » Wed, 16 Jan 2002 23:38:34


SORRY THE ERROR IS THIS:

Event Name  : OnSave
 URL of Source Item: file://./backofficestorage/ntdomain.test/Public
Folders/Archive/FW%3A TEST OF MESSAGE WITH 3 ATTCH.EML
 Flags (0x41): EVT_NEW_ITEM  EVT_INITNEW
-2147024809 The parameter is incorrect.

WIM


Quote:> Hi out there,

> I am trying to save each message & there attachments to disk.

> I created an event sink for this, the code looks like this:

> Private Sub IExStoreAsyncEvents_OnSave(ByVal pEventInfo As
> IExStoreEventInfo, ByVal bstrURLItem As String, ByVal lFlags As Long)

>     Dim rec As New ADODB.Record
>     Dim conn As New ADODB.Connection
>     Dim msg As New CDO.Message
>     Dim X As Integer
>     Dim copiedmsg As New CDO.Message
>     Dim strContentClass As String
>     Dim strMessageBody As String

>     conn.Provider = "Exoledb.datasource"

>     conn.Open "file://./backofficestorage/ntdomain.test/Public
> Folders/Archive/"

>     Call EventLog("OnSave", bstrURLItem, IFlags, "Conn open")

>     rec.Open bstrURLItem, conn

>     Call EventLog("OnSave", bstrURLItem, IFlags, "rec open")

>     msg.DataSource.Open bstrURLTem, conn, adModeReadWrite
>     Call EventLog("OnSave", bstrURLItem, IFlags, "msg open")

>     strMessageBody = msg.TextBody
>     Call EventLog("OnSave", bstrURLItem, IFlags, strMessageBody)

>     msg.GetStream.SaveToFile "c:\temp\msg.txt"

>     rec.Close
>     conn.Close
>     Set rec = Nothing
>     Set conn = Nothing

> Exit Sub

> Each time i try to open the message with the
> msg.DataSource.Open bstrURLTem, conn, adModeReadWrite
> i get an error:

> Event Name:OnASyncSave
>  URL of Source Item: file://./backofficestorage/ntdomain.test/Public
> Folders/Archive/testing 123 part2.EML
>  Flags (0x41): EVT_NEW_ITEM  EVT_INITNEW
>  COMMENT:

> when substitute the line with:

> msg.DataSource.Open file://./backofficestorage/ntdomain.test/Public
> Folders/Archive/testing 123 part2.EML, conn, adModeReadWrite

> it works fine, how can i let it work with the bstrlURLItem variable as is
> suppose to work...

> PLEASE anyone HELP ME

> Regards,
> Wim Mintiens


 
 
 

PROBLEM using event sink, cdo, saving message and attchments to disk

Post by Thomas Rizz » Thu, 17 Jan 2002 03:34:03


Are you sure the variable is getting set?  You can debug a VB Event Handler
just like any other VB component.  Just set a break point, kick the
component into the de* and trigger your event.  Then, you can track
down what is wrong.

Tom

--
Looking for a good book on developing using ADSI, Outlook 2000 and Exchange
5.5/2000?  Check out:
http://www.veryComputer.com/
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2002 Microsoft Corporation. All rights
reserved.


> SORRY THE ERROR IS THIS:

> Event Name  : OnSave
>  URL of Source Item: file://./backofficestorage/ntdomain.test/Public
> Folders/Archive/FW%3A TEST OF MESSAGE WITH 3 ATTCH.EML
>  Flags (0x41): EVT_NEW_ITEM  EVT_INITNEW
> -2147024809 The parameter is incorrect.

> WIM



> > Hi out there,

> > I am trying to save each message & there attachments to disk.

> > I created an event sink for this, the code looks like this:

> > Private Sub IExStoreAsyncEvents_OnSave(ByVal pEventInfo As
> > IExStoreEventInfo, ByVal bstrURLItem As String, ByVal lFlags As Long)

> >     Dim rec As New ADODB.Record
> >     Dim conn As New ADODB.Connection
> >     Dim msg As New CDO.Message
> >     Dim X As Integer
> >     Dim copiedmsg As New CDO.Message
> >     Dim strContentClass As String
> >     Dim strMessageBody As String

> >     conn.Provider = "Exoledb.datasource"

> >     conn.Open "file://./backofficestorage/ntdomain.test/Public
> > Folders/Archive/"

> >     Call EventLog("OnSave", bstrURLItem, IFlags, "Conn open")

> >     rec.Open bstrURLItem, conn

> >     Call EventLog("OnSave", bstrURLItem, IFlags, "rec open")

> >     msg.DataSource.Open bstrURLTem, conn, adModeReadWrite
> >     Call EventLog("OnSave", bstrURLItem, IFlags, "msg open")

> >     strMessageBody = msg.TextBody
> >     Call EventLog("OnSave", bstrURLItem, IFlags, strMessageBody)

> >     msg.GetStream.SaveToFile "c:\temp\msg.txt"

> >     rec.Close
> >     conn.Close
> >     Set rec = Nothing
> >     Set conn = Nothing

> > Exit Sub

> > Each time i try to open the message with the
> > msg.DataSource.Open bstrURLTem, conn, adModeReadWrite
> > i get an error:

> > Event Name:OnASyncSave
> >  URL of Source Item: file://./backofficestorage/ntdomain.test/Public
> > Folders/Archive/testing 123 part2.EML
> >  Flags (0x41): EVT_NEW_ITEM  EVT_INITNEW
> >  COMMENT:

> > when substitute the line with:

> > msg.DataSource.Open file://./backofficestorage/ntdomain.test/Public
> > Folders/Archive/testing 123 part2.EML, conn, adModeReadWrite

> > it works fine, how can i let it work with the bstrlURLItem variable as
is
> > suppose to work...

> > PLEASE anyone HELP ME

> > Regards,
> > Wim Mintiens

 
 
 

PROBLEM using event sink, cdo, saving message and attchments to disk

Post by Wim Mintien » Thu, 17 Jan 2002 16:30:11


Tom,
yes i am sure the variable is set, I logged each step of the program.
about that debugging... how do I have to that ? an Exchange event sink is a
dll that is running on
the exchange server as a com component. could you give me a hint on this??
regards,
Wim -10S


> Are you sure the variable is getting set?  You can debug a VB Event
Handler
> just like any other VB component.  Just set a break point, kick the
> component into the de* and trigger your event.  Then, you can track
> down what is wrong.

> Tom

> --
> Looking for a good book on developing using ADSI, Outlook 2000 and
Exchange
> 5.5/2000?  Check out:
> http://www.veryComputer.com/
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use. ? 2002 Microsoft Corporation. All rights
> reserved.



> > SORRY THE ERROR IS THIS:

> > Event Name  : OnSave
> >  URL of Source Item: file://./backofficestorage/ntdomain.test/Public
> > Folders/Archive/FW%3A TEST OF MESSAGE WITH 3 ATTCH.EML
> >  Flags (0x41): EVT_NEW_ITEM  EVT_INITNEW
> > -2147024809 The parameter is incorrect.

> > WIM



> > > Hi out there,

> > > I am trying to save each message & there attachments to disk.

> > > I created an event sink for this, the code looks like this:

> > > Private Sub IExStoreAsyncEvents_OnSave(ByVal pEventInfo As
> > > IExStoreEventInfo, ByVal bstrURLItem As String, ByVal lFlags As Long)

> > >     Dim rec As New ADODB.Record
> > >     Dim conn As New ADODB.Connection
> > >     Dim msg As New CDO.Message
> > >     Dim X As Integer
> > >     Dim copiedmsg As New CDO.Message
> > >     Dim strContentClass As String
> > >     Dim strMessageBody As String

> > >     conn.Provider = "Exoledb.datasource"

> > >     conn.Open "file://./backofficestorage/ntdomain.test/Public
> > > Folders/Archive/"

> > >     Call EventLog("OnSave", bstrURLItem, IFlags, "Conn open")

> > >     rec.Open bstrURLItem, conn

> > >     Call EventLog("OnSave", bstrURLItem, IFlags, "rec open")

> > >     msg.DataSource.Open bstrURLTem, conn, adModeReadWrite
> > >     Call EventLog("OnSave", bstrURLItem, IFlags, "msg open")

> > >     strMessageBody = msg.TextBody
> > >     Call EventLog("OnSave", bstrURLItem, IFlags, strMessageBody)

> > >     msg.GetStream.SaveToFile "c:\temp\msg.txt"

> > >     rec.Close
> > >     conn.Close
> > >     Set rec = Nothing
> > >     Set conn = Nothing

> > > Exit Sub

> > > Each time i try to open the message with the
> > > msg.DataSource.Open bstrURLTem, conn, adModeReadWrite
> > > i get an error:

> > > Event Name:OnASyncSave
> > >  URL of Source Item: file://./backofficestorage/ntdomain.test/Public
> > > Folders/Archive/testing 123 part2.EML
> > >  Flags (0x41): EVT_NEW_ITEM  EVT_INITNEW
> > >  COMMENT:

> > > when substitute the line with:

> > > msg.DataSource.Open file://./backofficestorage/ntdomain.test/Public
> > > Folders/Archive/testing 123 part2.EML, conn, adModeReadWrite

> > > it works fine, how can i let it work with the bstrlURLItem variable as
> is
> > > suppose to work...

> > > PLEASE anyone HELP ME

> > > Regards,
> > > Wim Mintiens

 
 
 

1. How to get CDO.IMessage object FileName when using OnArrival Event Sink

I am trying to write an Event Sink routine under CDO for Windows 2000 and/or
CDO for Exchange 2000.
My problem is when I catch the incoming message via CDO.IMessage object, I
just can not get the FileName prop of it.
I do all of these under Windows 2000 SMTP service which dropping the
incoming email message into the drop directory such as
c:\Inetpub\mailroot\Drop.
I found that when the OnArrival event sink is in action, the new incoming
message is not dropped into the drop directory yet. That means I can not use
IMessages interface to receive the FileName of the new IMessage object.
Does anybody know how to get the FileName such as *******.eml in this case.

2. Multiple Global Address Books Or Address Book by Group

3. Creating an Auto-Reply using CDO OnArrival Event Sink

4. Internet email

5. CDO Message sizxe and event sink

6. Exchange 2000 --- What the HELL did they do?!?

7. Post a message to a distribution list with CDO in an event sink

8. Spam questions...

9. Saving my message on disk - problem with header

10. message filtering using event sinks

11. Strange formatting problem when adding an X- header to outgoing message via CDO advise sink

12. Using VBScript with event sinks (onsave event)