Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DocumenContext fails

Posted on 2003-02-28
17
Medium Priority
?
212 Views
Last Modified: 2013-12-18
Hi,
I am trying to capture the contents of a mail. SO I have created an agent(shared agent) (After new mail has arrived).
But after debugging I have found that :
     Set doc = session.DocumentContext
     Ifrom = doc.from(0) ----> fails ??? Any reason
I have tried an alternate ways bu still fails :
Set it = doc.GetFirstItem("Subject")
but it also fails.
Here is the detail code :
-----------
Sub Initialize
     Dim session As NotesSession
     Set session = New NotesSession
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Dim dbug As NotesLog
     Dim rtitem As Variant
     Dim fileCount As Integer
     Dim it As NotesItem
     Dim user As String
'     REM get the incoming mail message
     Set doc = session.documentcontext
'REM Specify the size limit for attachments
     Const MaxSize = 0
     fileCount = 0
     Set dbug = New NotesLog("Router log")
     dbug.LogActions = True
     dbug.OpenAgentLog
     dbug.LogAction("begin")
     
     
     Open "c:\\umapada" & FileName & ".txt" For Output As #1
'REM Log the subject name of the message for debug purposes
     user = session.CommonUserName
     Set doc = session.DocumentContext
     Ifrom = doc.from(0)   ' this  fails  ..any reason
     dbug.LogAction("umapada" )
     Set it = doc.GetFirstItem("Subject")
     Write #1, "Subject "
     Write #1,it.Text
     Write#1,"****************************************************************************"
     dbug.LogAction("doc subject from context" + "-> " + it.Text)
     Set rtitem = doc.GetFirstItem( "Body" )
     Write #1, "Body"
     Write #1, rtitem.Text
     Write #1,"****************************************************************************"
     dbug.LogAction("Mail preprocessing agent is done")
     dbug.Close
End Sub



-----------

Any comment will be highly appreciated.

thanks in advance,
umapada
0
Comment
Question by:umapada
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +2
17 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 200 total points
ID: 8041478
You get a DocumentCollection with new mail documents.

Try something like this:

Sub Initialize
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim dc As NotesDocumentCollection
     Dim doc As NotesDocument
     Set db = session.CurrentDatabase
     Set dc = db.UnprocessedDocuments
     Set doc = dc.GetFirstDocument
     Do While Not (doc Is Nothing)
          Print "Subject: " & doc.Subject(0)
          Set doc = dc.GetNextDocument(doc)
     Loop
End Sub

0
 
LVL 5

Expert Comment

by:snocross
ID: 8041722
What do you mean by 'it fails'?  When you step through in debug mode and you reach that line of code what happens?  Does the code stop working and display an error or do you just find that the IForm value appears to be null?
0
 
LVL 5

Expert Comment

by:snocross
ID: 8041725
... I meant 'IFrom' by the way....
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 7

Assisted Solution

by:scottrma
scottrma earned 200 total points
ID: 8043277
The DocumentContext property does not always return a valid handle in (After New Mail Arrives) agents. This is because there may be multiple mails that get delivered before amgr actually queues the agent to run. Therefore, it is better to use session.CurrentDatabase.UnprocessedDocuments and loop through this collection, as in Zvonko's example above, with this type of agent (even though there may be only one document in the collection). DocumentContext is still useful in (Before New Mail Arrives) agents, among other things.

Regards,

Scott
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 8043626
Hey Zvo-Bro & Sno-Bro !

Yet again I excelled in stealing from my bro!

Sorry buddy...I could not resist it.

;-)
0
 
LVL 5

Expert Comment

by:snocross
ID: 8043735
Arun, not sure of which question you are refering to.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 8043767
He is hoping to get this one :-)
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 8043788
Sh!t Thief!!!
He managed again to steal 100 of mines and 100 of Heman's points!!!

Ok ok, congrats' Bro :-)

0
 
LVL 5

Expert Comment

by:snocross
ID: 8043802
I'm confused.
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 8043808
Look at the previously answered question.  The title of the question says "Points for Zvonko" LOL !!!

I didn't try to steal Hemans points by the way...

:-)
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 8043831
So it's special honor to be stolen by Bro!

Thanks, I will do you the same :-)

0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 8043853
As you see i am no longer actively participating here at EE.  Even if you steal it will be an honor for me !
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 8044084
Yes, I see, and I am sad about it Bro, really.
Just few days ago I got my cable modem and flat rate. Now we could chat anytime here. Instead of chatting I have to answer questions like this one! Why do I not get my email document here and not there and so on. And he is not even interested in his/her question. Afterwards he/she grades a B and says "thanks" :(
0
 

Author Comment

by:umapada
ID: 8055951
Thanks scottrma ,
 I have got ur points.


regards,
umapada
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 8056123
...or he/she even don't talk to you :-)

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question