Question

Lotus notes mail in asp.net gridview control

Asked by: kahvedzic

with this code I have content of Lotus mailbox in Listbox, but actually I need to have this data in gridview or table so I can insert this in SQL server database. Every listbox should be one column of gridview/table. This is realy urgent. Thanks

Imports Domino
 
Partial Class Default6
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim appNotes As NotesSession
        appNotes = New NotesSession
        Dim dbNotes As NotesDatabase
        appNotes.Initialize()
        dbNotes = appNotes.GetDatabase("server", "database")
        Dim vwInbox As NotesView
        vwInbox = dbNotes.GetView("$Inbox")
        Dim docMessage As NotesDocument
        On Error Resume Next
        With vwInbox
            docMessage = .GetLastDocument
            Do
                Dim v As Object
                v = appNotes.Evaluate("@Right(@Left(From; ""/""); ""CN="")", docMessage)
                List1.Items.Add(v(0))
                'List1.Items.Add(docMessage.GetItemValue("From"))
                'List1.Items.Add(Join(docMessage.GetItemValue("From")))
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
        End With
        On Error Resume Next
        With vwInbox
            docMessage = .GetLastDocument
            Do
                Dim sbj As Object
                sbj = appNotes.Evaluate(("Subject"), docMessage)
                List2.Items.Add(sbj(0))
                'List2.Items.Add(docMessage.GetItemValue("Subject")(0))
                'List2.Items.Add(Join(docMessage.GetItemValue("Subject")(0)))
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
        End With
        On Error Resume Next
        With vwInbox
            docMessage = .GetLastDocument
            Do
                'Dim bdy As Object
                'bdy = appNotes.Evaluate(("@Text(@Body)", docMessage)
                'List3.Items.Add(bdy(0))
                List3.Items.Add(docMessage.GetItemValue("Body"))
                List3.Items.Add(Join(docMessage.GetItemValue("Body")))
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
        End With
        On Error Resume Next
        With vwInbox
            docMessage = .GetLastDocument
            Do
                Dim time As Object
                time = appNotes.Evaluate("@Text(DeliveredDate)", docMessage)
                List4.Items.Add(time(0))
                'List4.Items.Add(docMessage.GetItemValue(("Created")))
                'List4.Items.Add(Join(docMessage.GetItemValue(("Created"))))
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
        End With
        On Error Resume Next
        With vwInbox
            docMessage = .GetLastDocument
        Do
                Dim attachmentNames As Object
                attachmentNames = appNotes.Evaluate("@Implode(@AttachmentNames; "", "")", docMessage)
                If attachmentNames <> "" Then
                    List5.Items.Add(attachmentNames(0))
                End If
                List5.Items.Add(" ")
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
        End With
        'Dim attachmentNames As Object
        'attachmentNames = appNotes.Evaluate("@Implode(@AttachmentNames; "", "")", docMessage)
        'List5.Items.Add(attachmentNames(0))
        'If attachmentNames = "" Then
        '    List5.Items.Add(" ")
        'Else
        '    List5.Items.Add(attachmentNames(0))
        'End If
        'docMessage = .GetPrevDocument(docMessage)
        'Dim attachmentNames As Object
        'attachmentNames = appNotes.Evaluate("@Implode(@AttachmentNames; "", "")", docMessage)
        'List5.Items.Add(attachmentNames(0))
        'If attachmentNames <> "" Then
        '    List5.Items.Add(attachmentNames(0))
        'End If
        'List5.Items.Add(" ")
        'docMessage = .GetPrevDocument(docMessage)
        On Error Resume Next
        docMessage = Nothing
        vwInbox = Nothing
        dbNotes = Nothing
        appNotes = Nothing
    End Sub
End Class

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-30 at 04:09:08ID24857632
Tags

gridview

,

Lotus Notes

,

Inbox

,

asp.net

Topic

Lotus Notes

Participating Experts
1
Points
500
Comments
23

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. enable a user with mailbox in a lotus domino
    hi can anyone help me out i dont know how to create a registered user with mailboxes in lotus domino environment.
  2. lotus to outlook migration
    I am performing a lotus client 6. to outlook. I have mirgrated the mailboxes but the users had mail list (groups) on the local lotus client is there an easy way to migtare those to outlook? Thank you
  3. Are there tools to convert lotus Notes mail files to Exchange…
    We want to convert are Lotus Notes User Mail files from Lotus Notes to Exchange mailboxes? Are there tools out there we can use?
  4. Lotus notes
    I have user who bought a wide screen laptop and having issue with changing the fonts. He would like to change the fonts for his mailbox. His emails subject and names are showing small inside the mailbox. I am not sure if there is any special setting to change since each file ...
  5. Access VBA and Lotus Notes
    I have a button on an Access form, when the user clicks on it an email is sent via Lotus Notes. Is there anyway to only create the email but not actually send it?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: kahvedzicPosted on 2009-11-02 at 06:25:42ID: 25719519

any chance someone can help me

 

by: kahvedzicPosted on 2009-11-04 at 07:15:09ID: 25740123

Is it posible to insert data from Lotus database in any control other than ListBox, that I can later fill GridView from. It is really urgent stuff so please help. Thanks all

 

by: sjef_bosmanPosted on 2009-11-07 at 01:06:03ID: 25765513

If you have to do the export/import only once, wouldn't it be a lot easier to export the contacts to a file, then import it in your SQL tables? Or write some agent/script in Lotus Notes to add the data directly to the SQL database? Or use LEI to connect to the SQL database?

PS I know nothing of grids, so I'm merely asking why you want to go through all the trouble to create a rather complex application to transfer some data...

 

by: kahvedzicPosted on 2009-11-10 at 05:17:02ID: 25784992

Solution was to create datatable, insert data from LN database to it and then use datatable as datasource for GridView. Thanx for your help anyway

 

by: sjef_bosmanPosted on 2009-11-10 at 05:55:52ID: 25785328

Yes, I saw you got that solution in a different question... Get this question deleted, I'd say.

 

by: kahvedzicPosted on 2009-11-10 at 06:31:12ID: 25785686

No it is not still deleted because I now realise that I need a body as an object and not like I did with join. Can you help me, as you can see all other parameters I get as an object except Body that I get with a join, and in that way I cant insert it in a datatable. Thanks again

 

by: kahvedzicPosted on 2009-11-10 at 06:59:23ID: 25786000

got it

 With vwInbox
            docMessage = .GetLastDocument
            Do
                Dim bdy As Object
                bdy = appNotes.Evaluate("@Text(Body)", docMessage)
                List3.Items.Add(bdy(0))
                'List3.Items.Add(docMessage.GetItemValue("Body"))
                'List3.Items.Add(Join(docMessage.GetItemValue("Body")))
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
        End With
        On Error Resume Next

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:

Select allOpen in new window

 

by: sjef_bosmanPosted on 2009-11-10 at 07:51:44ID: 25786538

That's not the right way to get the Body field. Evaluate shouldn't be used for every field, and certainly not when you don't need it. I think I mentioned the proper code to get Rich-text fields in some other question of yours.

Anyway, try this:

With vwInbox
            docMessage = .GetLastDocument
            Do
                Dim bdy As String
                bdy = docMessage.GetItemValue("Body").Text
                List3.Items.Add(bdy)
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
End With

 

by: kahvedzicPosted on 2009-11-10 at 23:18:05ID: 25792882

I tried your code, with evaluate I get body as plain text and can insert it in text field in sql database table, but with GetItemValue list box is empty and no text at all.

 

by: sjef_bosmanPosted on 2009-11-11 at 00:23:45ID: 25793140

Strange... Here's a different way:

With vwInbox
            docMessage = .GetLastDocument
            Do
                Dim bdy As String
                bdy = docMessage.GetItemValue("Body").GetUnformattedText( )
                List3.Items.Add(bdy)
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
End With

Or a two-step approach:

With vwInbox
            docMessage = .GetLastDocument
            Do
                Dim obdy As Object
                Dim bdy As String
                obdy = docMessage.GetItemValue("Body")
                bdy = obdy.Text
                List3.Items.Add(bdy)
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
End With

 

by: kahvedzicPosted on 2009-11-11 at 02:23:08ID: 25793731

no, nothing again, in both ways I get empty listbox.

 

by: sjef_bosmanPosted on 2009-11-11 at 02:44:49ID: 25793844

Just leave the Evaluate then, it's the pragmatic thing to do. I'm kinda baffled...

 

by: kahvedzicPosted on 2009-11-11 at 03:40:35ID: 25794182

I did that and it works. But I have problem with attachment names again, still getting 2 rows in listbox for mails with attachments. In one row I have attachment names and second row is empty. Second row is problem because now I have more rows in attachment listbox then in other listboxes. How to get only one row with attachment names?

 

by: sjef_bosmanPosted on 2009-11-11 at 05:14:23ID: 25794705

The attachmentNames variable is filled with one string containing the names of the attachments, separated by comma and space. Could it be that VB or your code splits it up? What does the statement    List5.Items.Add(" ")   do exactly?

 

by: kahvedzicPosted on 2009-11-11 at 05:54:47ID: 25795054

List5.Items.Add(" ") is suppose to insert empty string for mails without attachment. If I remove this line of code I only get list of all attachments without empty rows for mails without attachment. Actually I need empty string in ListBox for mail without attachment and string with attachment names for mails with attachment.

 

by: sjef_bosmanPosted on 2009-11-11 at 06:46:36ID: 25795463

So that line should ONLY be executed if there are no attachments at all? Aaargh, your code is too complex! Consider this approach:
- one outer loop over the documents
- inside the loop: you add one entry to each list, always

Might that be better??

 

by: kahvedzicPosted on 2009-11-11 at 07:23:27ID: 25795770

yes this line of code is only for mails that are without any attachment, just like I said in first question that was posted. Can you give me some more details about your approach with two loops.

 

by: sjef_bosmanPosted on 2009-11-11 at 09:20:59ID: 25796959

Somehow, the EE-site got all garbled up. I hope they can correct it soon. Anyway, here's a different view on matters. The idea would be that you don't cycle through all documents 10 times, but you do it once and you pick up all data you need on the way.

See the code below (not tested, just to give you the general idea). The code is not updated with your latest changes!

Imports Domino
 
Partial Class Default6
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim appNotes As NotesSession
        appNotes = New NotesSession
        Dim dbNotes As NotesDatabase
        appNotes.Initialize()
        dbNotes = appNotes.GetDatabase("server", "database")
        Dim vwInbox As NotesView
        vwInbox = dbNotes.GetView("$Inbox")
        Dim docMessage As NotesDocument
        On Error Resume Next
        With vwInbox
            docMessage = .GetLastDocument
            Do
                Dim v As Object
                v = appNotes.Evaluate("@Right(@Left(From; ""/""); ""CN="")", docMessage)
                List1.Items.Add(v(0))
                Dim sbj As Object
                sbj = appNotes.Evaluate(("Subject"), docMessage)
                List2.Items.Add(sbj(0))
                List3.Items.Add(docMessage.GetItemValue("Body"))
                List3.Items.Add(Join(docMessage.GetItemValue("Body")))
                Dim time As Object
                time = appNotes.Evaluate("@Text(DeliveredDate)", docMessage)
                List4.Items.Add(time(0))
                'List4.Items.Add(docMessage.GetItemValue(("Created")))
                'List4.Items.Add(Join(docMessage.GetItemValue(("Created"))))
                Dim attachmentNames As Object
                attachmentNames = appNotes.Evaluate("@Implode(@AttachmentNames; "", "")", docMessage)
                List5.Items.Add(attachmentNames(0))
                docMessage = .GetPrevDocument(docMessage)
            Loop Until docMessage Is Nothing
        End With
        On Error Resume Next
        docMessage = Nothing
        vwInbox = Nothing
        dbNotes = Nothing
        appNotes = Nothing
    End Sub
End Class

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:

Select allOpen in new window

 

by: kahvedzicPosted on 2009-11-11 at 23:44:55ID: 25802209

this is working fine, a little bit faster, except the part with attachment listbox. Now I need that empty strings only for mails without attachments.

 

by: sjef_bosmanPosted on 2009-11-12 at 15:58:25ID: 25810177

A little faster, but a lot less code. And it should be a lot faster when there are many documents in the view.

About the mails without attachments: is that why you added a string with a single space?

Try this quick hack then:

                Dim attachmentNames As Object
                attachmentNames = appNotes.Evaluate("@Implode(@AttachmentNames; "", "")", docMessage)
            If attachmentNames(0)="" Then attachmentNames(0)=" "
                List5.Items.Add(attachmentNames(0))

 

by: kahvedzicPosted on 2009-11-16 at 05:57:38ID: 25830231

quick hack works fine, let me check everything and then finish with this question. OK?

 

by: sjef_bosmanPosted on 2009-11-16 at 12:42:09ID: 25833886

Fine with me! :-)

 

by: sjef_bosmanPosted on 2009-12-01 at 14:34:48ID: 25947498

:-))

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...