Autor Thema: Mail mit mehrere dynamischen Tabellen  (Gelesen 2582 mal)

Offline sja

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Weiblich
  • Ich liebe dieses Forum!
Mail mit mehrere dynamischen Tabellen
« am: 27.02.06 - 11:32:34 »
Hallo @All,

Habe folgendes Problem und vielen Dank für jede Hilfe!

Ein Agent soll eine Email senden. Die Email soll die Tabellen für alle Mitarbeiter mit allen Terminen aktueller Woche enthalten. D. h. in eine Mail sollen alle Tabellen  gepackt werden.
Als Grundlage benutze ich Datenbank RTNavSample.zip s. 1. Anhang.
Habe schon danach verschiedene Agenten gemach, die ohne Problem funktionieren, allerdings, es wurde nur eine Tabelle je Email gebildet.

Problem habe ich, wenn die Mail mehrere Tabellen erhalten soll. Meine Code für die Email mit mehre Tabellen s. 2. Anhang.

Die Problembeschreibung:
die Message1, Message2 und die Gitter für nächste Tabelle werden richtig erstellet, aber Kopf und Zeilen-Ausfüllung werden immer wieder in der erste Tabelle gemacht. Weiss nicht ob ich verständlich mein Problem erklärt habe?

Herzlichen Dank für jede Hilfe im Voraus!

Schoene Gruesse
Sofia
« Letzte Änderung: 28.02.06 - 10:55:29 von sja »

Offline sja

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Weiblich
  • Ich liebe dieses Forum!
Re: Mail mit mehre dynamischen Tabellen
« Antwort #1 am: 27.02.06 - 11:39:21 »
Hier ist mein Code, wenn jemand daran Interesse hat und helfen würde, vielen Dank

Option Public
Option Declare
'Use "libSort"

Const COLUMN_COUNT = 9                  ' <<< EDIT this value to match the number of columns in the output table

' Error trapping constants
Const ERR_EXITNOMSG = 1000
Const MSG_EXITNOMSG = ""
Const ERR_NODOCSELECTED = 1001
Const MSG_NODOCSELECTED = "Please select the document(s) on which you wish to report."


Dim session As NotesSession
Dim db As NotesDatabase
Dim srv As String

Dim doc As NotesDocument
Dim docAll As NotesDocument
Dim MailDoc As NotesDocument

Dim body As NotesRichTextItem
Dim rtStyle As NotesRichTextStyle
Dim rtHelvPlain8 As NotesRichTextStyle
Dim rtHelv8_Black_Bold As NotesRichTextStyle
Dim rtTable As NotesRichTextTable
Dim rtNav As NotesRichTextNavigator
Dim totalRows As Integer
Dim i As Integer
Dim col As Integer
Dim item As NotesItem
Dim strRptLine As String
Dim isFirstLine As Integer

Dim view As NotesView
Dim viewAll As NotesView
Dim vecAll As NotesViewEntryCollection
Dim vec As NotesViewEntryCollection   
Dim ve As NotesViewEntry
Dim key As String
Dim GrVB As Variant

Dim an As String
Dim Betreff As String
Dim Message1 As String
Dim Message2 As String

Dim strErrMsg As String

Dim Woche As Integer
Dim Jahr As Integer
Dim Monat As Integer

Sub Initialize
   On Error Goto errHandler
   
   Set session = New NotesSession
   Set db = session.CurrentDatabase
   Set view=db.getview("Termine")
   'Set viewAll=db.getview("TermineAll")
   srv = db.Server
   
   Woche = CalculateWeekNo (Today)
   Jahr =  Year(Today)
   
   Set vecAll = view.AllEntries   
'****************************************************************   
   If Not(vecAll.Count = 0) Then   
   '****************************************************************************************   
      Betreff = "PYM -> Terminplanung für "   &_
      " / "  &  Jahr & " Kalenderwochen "  & Woche_1 & " und "  & Woche
   
      an = "UserName"
      
      Set MailDoc = New NotesDocument(db)
      MailDoc.Form = "Memo"
      MailDoc.Subject = Betreff
      MailDoc.SendTo = an
      MailDoc.BlindCopyTo = "Sofia Jaschin"
      Set body = New NotesRichTextItem( MailDoc , "Body" )   
   '****************************************************************************************         
      GrVB = Evaluate({@Name([CN];@DbLookup( "":"NoCache"; "} + srv +_
 {" : "names.nsf" ; "($VIMGroups)" ; "VB" ; 3 ))})
      
      Forall Key In GrVB               
         Set vec = view.GetAllEntriesByKey(key, True)
         If Not(vec.Count = 0) Then
            Message1 = "Auflistung der Termine für vorherige Kalenderwoche "   & Woche_1 &_
            " und aktuelle Kalenderwoche "  & Woche  & " für " & key & Chr(13) & Chr(13)
            
            Message2 = "->  "  & key & " / "  &  Jahr  & " / KW" & tmpWoche   
      
            Call body.AppendText( Message1)
            Call body.AppendText( Message2)
            
            totalRows = vec.Count + 1
            
            Call setRichTextStyles   
            
            If Not createReport Then Error ERR_EXITNOMSG, MSG_EXITNOMSG
            Call populateTable      
         End If
      End Forall
   '****************************************************************************************               
      MailDoc.Send(False)
   '****************************************************************************************         
   End If
'****************************************************************   
finally:
   Exit Sub
   
errHandler:
   Select Case Err
   Case ERR_EXITNOMSG
      ' Any needed message was displayed elsewhere, so just exit
   Case ERR_NODOCSELECTED
      Msgbox MSG_NODOCSELECTED, 64, db.Title
   Case Else
      strErrMsg = "Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
      Msgbox strErrMsg, 16, "Unexpected error"
   End Select
   
   Resume finally   
   
End Sub

Sub setRichTextStyles
   On Error Goto errHandler
   
   Set rtHelvPlain8 = session.CreateRichTextStyle
   rtHelvPlain8.NotesFont = FONT_HELV
   rtHelvPlain8.FontSize = 8
   rtHelvPlain8.NotesColor = COLOR_BLACK
   rtHelvPlain8.Bold = False
   rtHelvPlain8.Italic = False
   rtHelvPlain8.Underline = False
   
   Set rtHelv8_Black_Bold = session.CreateRichTextStyle
   rtHelv8_Black_Bold.NotesFont = FONT_HELV
   rtHelv8_Black_Bold.FontSize = 8
   rtHelv8_Black_Bold.NotesColor = COLOR_BLACK
   rtHelv8_Black_Bold.Bold = True
   rtHelv8_Black_Bold.Italic = False
   rtHelv8_Black_Bold.Underline = False
   
finally:
   Exit Sub
   
errHandler:
   Dim strMsg As String
   strMsg = "Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
   Msgbox strMsg, 16, db.Title & ": Unexpected error"
   Resume finally   
End Sub

Function createReport() As Integer
   On Error Goto errHandler
   
   createReport = True                                                         
   
   Dim color As NotesColorObject                                                
   Dim columnHeader(9) As String                                             
   
   Dim tableColStyles(1 To 9) As NotesRichTextParagraphStyle
   
   columnHeader(1) = "Link"      ' Initialize column header values
   columnHeader(2) = "Datum"
   columnHeader(3) = "Von - Bis"
   columnHeader(4) = " Kundenname"
   columnHeader(5) = "Kontakt Typ"
   columnHeader(6) = " Projektname"
   columnHeader(7) = "Produkt"
   columnHeader(8) = "Zielsetzung"
   columnHeader(9) = "Ergebnis"
   
   
' Populate the array of NotesRichTextParagraphStyle - one array element (one NotesRichTextParagraphStyle) for each column.
   For i = 1 To COLUMN_COUNT Step 1
      Set tableColStyles(i) = session.CreateRichTextParagraphStyle   ' Create the rt paragraph style for this column
      tableColStyles(i).FirstLineLeftMargin = 0                                    ' Set left margin for the first line of each cell in column
      tableColStyles(i).LeftMargin = 0                                             ' Set left margin for all but the first line of each cell in column
      Select Case i
         
      Case 1
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 0.7
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 2   
         'tableColStyles(i).LeftMargin = RULER_ONE_CENTIMETER * 0.1
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
      Case 3
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 3
      Case 4
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 4
      Case 5
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
      Case 6
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 7
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 8
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 9
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
         
      End Select
   Next
   
   Call body.AppendTable( totalRows, COLUMN_COUNT,,, tableColStyles)
   
   Set rtNav = body.CreateNavigator            
   Call rtNav.GetFirstElement(RTELEM_TYPE_TABLE)
   
   Set rtTable= rtNav.GetElement
   
   rtTable.Style = TABLESTYLE_TOP
   Set color = session.CreateColorObject            ' Create color object for use in setting cell colors
   color.NotesColor = COLOR_LIGHT_GRAY
   Call rtTable.SetColor( color )               ' Set the top row color to light gray background
   color.NotesColor = COLOR_WHITE
   Call rtTable.SetAlternateColor( color )            ' Set all rows after the top row to white background
   
   Call rtNav.FindFirstElement( RTELEM_TYPE_TABLECELL )   ' Move to the first cell - row 1, col 1
   Call body.AppendStyle( rtHelv8_Black_Bold  )         ' Set the font to Helvetica, 8-point, bold black
   For col = 1 To COLUMN_COUNT Step 1
      
      Call body.BeginInsert( rtNav )
      Call body.AppendText( columnHeader(col) )      ' Write the text for this column's header
      Call body.EndInsert                              ' Move insertion point to the end of this cell
      Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )   ' Move to the next cell
   Next
   
finally:
   Exit Function
   
errHandler:
   createReport = False
   Dim strErrMsg As String
   Select Case Err
   Case Else
      strErrMsg = "Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
      Msgbox strErrMsg, 16, "Unexpected error"
   End Select
   
   Resume finally
   
End Function

Function populateTable() As Integer
   On Error Goto errHandler
   populateTable = True         ' Function returns TRUE unless we hit an error
   
   Call body.AppendStyle( rtHelvPlain8 )      ' Set font to Helvetica, 8 point, black
   If Not(vec.Count = 0) Then
      Set ve = vec.GetFirstEntry()
      
      Do Until  ve Is Nothing
         Set doc= ve.Document
         
         For col = 1 To COLUMN_COUNT Step 1
            
            Call body.BeginInsert( rtNav )
            Select Case col            ' Populate the detail cells of the table
            Case 1
               Call body.AppendDocLink( doc, doc.KundenProjektTitel(0))
            Case 2
               Call body.AppendText( doc.StartDate(0) )
            Case 3
               Call body.AppendText( doc.TimeRange(0))
            Case 4
               Call body.AppendText( doc.KundenName(0) )
            Case 5
               Call body.AppendText( doc.Termin_Kontakt_Typ(0) )
            Case 6
               Call body.AppendText( doc.KundenProjektTitel(0) )
            Case 7
               Call body.AppendText( doc.Termin_cIT_Produkt(0) )
            Case 8
               Call body.AppendText( doc.Termin_Zielsetzung(0) )
            Case 9
               Call body.AppendText( doc.Termin_Ergebnis(0) )
               
            End Select
            Call body.EndInsert
            Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )            ' Move to the next table cell
         Next       
         Set ve = vec.getNextEntry(ve)
      Loop
   End If
   
finally:
   Exit Function
   
errHandler:
   populateTable = False
   Dim strErrMsg As String
   Select Case Err
   Case Else
      strErrMsg = "Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
      Msgbox strErrMsg, 16, "Unexpected error"
   End Select
   
   Resume finally
   
End Function

Gruesse
Sofia

Offline sja

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Weiblich
  • Ich liebe dieses Forum!
Re: Mail mit mehre dynamischen Tabellen
« Antwort #2 am: 27.02.06 - 12:06:30 »
hallo,

also, das Ergebniss sieht so aus (s. Anhang).

Hat jemand eine Idee? Danke schön

Gruesse
Sofia

Offline umi

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.062
  • Geschlecht: Männlich
  • one notes to rule'em all, one notes to find'em....
    • Belsoft AG
Re: Mail mit mehre dynamischen Tabellen
« Antwort #3 am: 27.02.06 - 13:03:03 »
Ja hab ich :-)

Habs kurz überflogen. Es könnte daran liegen dass Du nur auf die 1. Tabelle zugreifst ?
siehe z.B. den Code in createReport
Code
Call body.AppendTable( totalRows, COLUMN_COUNT,,, tableColStyles)
'erstellt eine neue Tabelle
   
   Set rtNav = body.CreateNavigator            
'>
   Call rtNav.GetFirstElement(RTELEM_TYPE_TABLE)
'>Diese Zeile holt aber wieder die 1. Tabelle, egal wieviele TAbellen Du erstellst :-)
   

bzw. in der Funktion populateTable auf den RTNav verwiesen wird von createReport.

Gruss

Urs

<:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jegliche Schreibfehler sind unpeabischigt
http://www.belsoft.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:>

Offline sja

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Weiblich
  • Ich liebe dieses Forum!
Re: Mail mit mehre dynamischen Tabellen
« Antwort #4 am: 27.02.06 - 14:04:52 »
Hallo Umi,

Danke schön für Deine Antwort.

Das verstehe ich, dass Navigator zu erster Tabelle geht,
Nur kann ich nicht begreifen, wie soll ich es organisieren, dass der Navigator zur neu erstellte Tabelle geht ???

Wenn jemand mir dabei helfen würde, herzlichen Dank.


Gruesse
Sofia
« Letzte Änderung: 27.02.06 - 14:10:27 von sja »

Offline umi

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.062
  • Geschlecht: Männlich
  • one notes to rule'em all, one notes to find'em....
    • Belsoft AG
Re: Mail mit mehre dynamischen Tabellen
« Antwort #5 am: 27.02.06 - 14:26:02 »
Nicht ganz schwierig :-)

z.B. durch übergabe eines Parameters an createReport

oder Du könntest auch die Anzahl tabellen in einer globalen Variablen speichern.

Code
Function createReport(tabell as integer) As Integer
   On Error Goto errHandler
   
   createReport = True                                                         
   
   Dim color As NotesColorObject                                                
   Dim columnHeader(9) As String                                             
   
   Dim tableColStyles(1 To 9) As NotesRichTextParagraphStyle
   
   columnHeader(1) = "Link"      ' Initialize column header values
   columnHeader(2) = "Datum"
   columnHeader(3) = "Von - Bis"
   columnHeader(4) = " Kundenname"
   columnHeader(5) = "Kontakt Typ"
   columnHeader(6) = " Projektname"
   columnHeader(7) = "Produkt"
   columnHeader( = "Zielsetzung"
   columnHeader(9) = "Ergebnis"
   
   
' Populate the array of NotesRichTextParagraphStyle - one array element (one NotesRichTextParagraphStyle) for each column.
   For i = 1 To COLUMN_COUNT Step 1
      Set tableColStyles(i) = session.CreateRichTextParagraphStyle   ' Create the rt paragraph style for this column
      tableColStyles(i).FirstLineLeftMargin = 0                                    ' Set left margin for the first line of each cell in column
      tableColStyles(i).LeftMargin = 0                                             ' Set left margin for all but the first line of each cell in column
      Select Case i
         
      Case 1
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 0.7
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 2   
         'tableColStyles(i).LeftMargin = RULER_ONE_CENTIMETER * 0.1
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
      Case 3
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 3
      Case 4
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 4
      Case 5
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
      Case 6
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 7
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 8
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 9
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
         
      End Select
   Next
   
   Call body.AppendTable( totalRows, COLUMN_COUNT,,, tableColStyles)
   
   Set rtNav = body.CreateNavigator            
   Call rtNav.GetFirstElement(RTELEM_TYPE_TABLE)
if (tabelle > 1 ) then
 for i=0 to tabelle-1
 call rtnav.getNextElement(RTELEM_TYPE_TABLE)
next

end if
   
   Set rtTable= rtNav.GetElement
   
   rtTable.Style = TABLESTYLE_TOP
   Set color = session.CreateColorObject            ' Create color object for use in setting cell colors
   color.NotesColor = COLOR_LIGHT_GRAY
   Call rtTable.SetColor( color )               ' Set the top row color to light gray background
   color.NotesColor = COLOR_WHITE
   Call rtTable.SetAlternateColor( color )            ' Set all rows after the top row to white background
   
   Call rtNav.FindFirstElement( RTELEM_TYPE_TABLECELL )   ' Move to the first cell - row 1, col 1
   Call body.AppendStyle( rtHelv8_Black_Bold  )         ' Set the font to Helvetica, 8-point, bold black
   For col = 1 To COLUMN_COUNT Step 1
      
      Call body.BeginInsert( rtNav )
      Call body.AppendText( columnHeader(col) )      ' Write the text for this column's header 
      Call body.EndInsert                              ' Move insertion point to the end of this cell
      Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )   ' Move to the next cell
   Next
   
finally:
   Exit Function
   
errHandler:
   createReport = False
   Dim strErrMsg As String
   Select Case Err
   Case Else
      strErrMsg = "Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
      Msgbox strErrMsg, 16, "Unexpected error"
   End Select
   
   Resume finally
   
End Function

Gruss

Urs

<:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jegliche Schreibfehler sind unpeabischigt
http://www.belsoft.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:>

Offline sja

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Weiblich
  • Ich liebe dieses Forum!
Re: Mail mit mehre dynamischen Tabellen
« Antwort #6 am: 27.02.06 - 15:16:39 »
Herzlichen Dank für Deine Hilfe, @umi!
Ich probiere das.

Gruesse
Sofia

Offline sja

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Weiblich
  • Ich liebe dieses Forum!
Re: Mail mit mehre dynamischen Tabellen
« Antwort #7 am: 27.02.06 - 17:03:49 »
hallo,

habe so gemacht:
   If Not (tabelle >1) Then
      Set rtNav = body.CreateNavigator            
      Call rtNav.GetFirstElement(RTELEM_TYPE_TABLE)
      
      Set rtTable= rtNav.GetElement
      
      rtTable.Style = TABLESTYLE_TOP
      Set color = session.CreateColorObject         ' Create color object for use in setting cell colors
      color.NotesColor = COLOR_LIGHT_GRAY
      Call rtTable.SetColor( color )                  ' Set the top row color to light gray background
      color.NotesColor = COLOR_WHITE
      Call rtTable.SetAlternateColor( color )            ' Set all rows after the top row to white background
      
      Call rtNav.FindFirstElement( RTELEM_TYPE_TABLECELL )   ' Move to the first cell - row 1, col 1
      Call body.AppendStyle( rtHelv8_Black_Bold  )            ' Set the font to Helvetica, 8-point, bold black
      For col = 1 To COLUMN_COUNT Step 1
         
         Call body.BeginInsert( rtNav )
         Call body.AppendText( columnHeader(col) )      ' Write the text for this column's header
         Call body.EndInsert                     ' Move insertion point to the end of this cell
         Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )   ' Move to the next cell
      Next
      
   Else
      Call rtNav.GetLastElement(RTELEM_TYPE_TABLE)
      
      Set rtTable= rtNav.GetElement
      
      rtTable.Style = TABLESTYLE_TOP
      Set color = session.CreateColorObject            ' Create color object for use in setting cell colors
      color.NotesColor = COLOR_LIGHT_GRAY
      Call rtTable.SetColor( color )                  ' Set the top row color to light gray background
      color.NotesColor = COLOR_WHITE
      Call rtTable.SetAlternateColor( color )            ' Set all rows after the top row to white background
      
      Call rtNav.FindFirstElement( RTELEM_TYPE_TABLECELL )   ' Move to the first cell - row 1, col 1
   'Call rtNav.FindNthElement( RTELEM_TYPE_TABLECELL , tabelle)   
      
      Call body.AppendStyle( rtHelv8_Black_Bold  )         ' Set the font to Helvetica, 8-point, bold black
      For col = 1 To COLUMN_COUNT Step 1
         
         Call body.BeginInsert( rtNav )
         Call body.AppendText( columnHeader(col) )      ' Write the text for this column's header
         Call body.EndInsert                  ' Move insertion point to the end of this cell
         Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )   ' Move to the next cell
      Next
   End If


jetzt color für den Tabelle-Kopf ist  für nächste Tabelle da, aber nicht mehr (s. Bild-Anhang)

 ???

für weitere Hilfe werde sehr dankbar!

  :'(

Offline umi

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.062
  • Geschlecht: Männlich
  • one notes to rule'em all, one notes to find'em....
    • Belsoft AG
Re: Mail mit mehre dynamischen Tabellen
« Antwort #8 am: 27.02.06 - 17:06:34 »
Kleiner Tipp: überprüf mal die Funktion populateTabelle... Welche RTNAv verwendet diese Funktion den richtigen RTNAv?
Gruss

Urs

<:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jegliche Schreibfehler sind unpeabischigt
http://www.belsoft.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:>

Offline sja

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Weiblich
  • Ich liebe dieses Forum!
Re: Mail mit mehre dynamischen Tabellen
« Antwort #9 am: 27.02.06 - 17:22:11 »
ich weiss nicht, wie kann ich auf erste Element in der letzten Tabelle zeigen


die poplate sieht so aus:

Function populateTable() As Integer
   On Error Goto errHandler
   populateTable = True         ' Function returns TRUE unless we hit an error
   
   Call body.AppendStyle( rtHelvPlain8 )      ' Set font to Helvetica, 8 point, black
   If Not(vec.Count = 0) Then
      Set ve = vec.GetFirstEntry()
      
      Do Until  ve Is Nothing
         Set doc= ve.Document
         
         For col = 1 To COLUMN_COUNT Step 1
            
            Call body.BeginInsert( rtNav )
            Select Case col               ' Populate the detail cells of the table
            Case 1
               Call body.AppendDocLink( doc, doc.KundenProjektTitel(0))
            Case 2
               Call body.AppendText( doc.StartDate(0) )
            Case 3
               Call body.AppendText( doc.TimeRange(0))
            Case 4
               Call body.AppendText( doc.KundenName(0) )
            Case 5
               Call body.AppendText( doc.Termin_Kontakt_Typ(0) )
            Case 6
               Call body.AppendText( doc.KundenProjektTitel(0) )
            Case 7
               Call body.AppendText( doc.Termin_cIT_Produkt(0) )
            Case 8
               Call body.AppendText( doc.Termin_Zielsetzung(0) )
            Case 9
               Call body.AppendText( doc.Termin_Ergebnis(0) )
               
            End Select
            Call body.EndInsert
            Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )   ' Move to the next table cell
         Next       
         Set ve = vec.getNextEntry(ve)
      Loop
   End If
   
finally:
   Exit Function
   
errHandler:
   populateTable = False
   Dim strErrMsg As String
   Select Case Err
   Case Else
      strErrMsg = "Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
      Msgbox strErrMsg, 16, "Unexpected error"
   End Select
   
   Resume finally
   
End Function

Offline sja

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Weiblich
  • Ich liebe dieses Forum!
Re: Mail mit mehre dynamischen Tabellen
« Antwort #10 am: 28.02.06 - 10:10:16 »
Hallo,

wenn jemand Interesse hat, ist hier meine Lösung, wie kommt man auf erste TableCell in letzter Tabelle (s. Kommentare in dem Code mit dem Anfang: '!!!). Leider kann ich nicht das wörtlich erklären.

Vielen Dank noch mal @umi für eine Idee, die Anzahl tabellen in einer globalen Variablen zu speichern!



Sub Initialize
…         
   GrVB = Evaluate({@Name([CN];@DbLookup( "":"NoCache"; "} + srv + {" : "names.nsf" ; "($VIMGroups)" ; "VB" ; 3 ))})

   tabelle = 0   '!!! Globale Variable

   Forall tmpGrVB In GrVB
         
      key = tmpGrVB
         
      Set vec = view.GetAllEntriesByKey(key, True)
      tmpWoche = Woche
      
      If Not(vec.Count = 0) Then

         tabelle = tabelle + 1    '!!! Für jede neue Tabelle

         Message1 = "Auflistung der Termine für vorherige Kalenderwoche "   & Woche_1 &_
            " und aktuelle Kalenderwoche "  & Woche  & " für " & key & Chr(13) & Chr(13)
            
         Message2 = "->  "  & key & " / "  &  Jahr  & " / KW" & tmpWoche   
            
            
         Call body.AppendText( Message1)
         Call body.AppendText( Message2)

         'If vec.Count = 0 Then Exit Function
         totalRows = vec.Count + 1
            
         Call setRichTextStyles   
            
         If Not createReport(tabelle) Then Error ERR_EXITNOMSG, MSG_EXITNOMSG
         Call populateTable(tabelle)
            
      End If
   End Forall
      
   MailDoc.Send(False)
…   
End Sub

Function createReport(tabelle) As Integer
   On Error Goto errHandler   
   createReport = True      
   Dim color As NotesColorObject                        
   Dim columnHeader(9) As String                        
   Dim tableColStyles(1 To 9) As NotesRichTextParagraphStyle
   
   columnHeader(1) = "Link"      ' Initialize column header values
   columnHeader(2) = "Datum"
   columnHeader(3) = "Von - Bis"
   columnHeader(4) = "PYM-Kundenname"
   columnHeader(5) = "Kontakt Typ"
   columnHeader(6) = "PYM-Projektname"
   columnHeader(7) = "cIT Produkt"
   columnHeader(8) = "Zielsetzung"
   columnHeader(9) = "Ergebnis"
   
' Populate the array of NotesRichTextParagraphStyle - one array element (one NotesRichTextParagraphStyle) for each column.
   For i = 1 To COLUMN_COUNT Step 1
      Set tableColStyles(i) = session.CreateRichTextParagraphStyle ' Create the rt paragraph style for this column
      tableColStyles(i).FirstLineLeftMargin = 0                                    ' Set left margin for the first line of each cell in column
      tableColStyles(i).LeftMargin = 0                                       ' Set left margin for all but the first line of each cell in column
      Select Case i
         
      Case 1
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 0.7
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 2   
         'tableColStyles(i).LeftMargin = RULER_ONE_CENTIMETER * 0.1
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
      Case 3
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 3
      Case 4
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 4
      Case 5
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
      Case 6
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 7
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 8
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
      Case 9
         tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
         tableColStyles(i).Alignment = ALIGN_CENTER
         
      End Select
   Next
   
   Call body.AppendTable( totalRows, COLUMN_COUNT,,, tableColStyles)
   Set rtNav = body.CreateNavigator         
   
   If Not (tabelle >1) Then      '!!!  Wird erste Tabelle erstellt
      Call rtNav.GetFirstElement(RTELEM_TYPE_TABLE)   
      Set rtTable= rtNav.GetElement
      
      rtTable.Style = TABLESTYLE_TOP
      Set color = session.CreateColorObject      ' Create color object for use in setting cell colors
      color.NotesColor = COLOR_LIGHT_GRAY
      Call rtTable.SetColor( color )         ' Set the top row color to light gray background
      color.NotesColor = COLOR_WHITE
      Call rtTable.SetAlternateColor( color )      ' Set all rows after the top row to white background
      
      Call rtNav.FindFirstElement( RTELEM_TYPE_TABLECELL )   ' Move to the first cell - row 1, col 1
      Call body.AppendStyle( rtHelv8_Black_Bold  )      ' Set the font to Helvetica, 8-point, bold black
      For col = 1 To COLUMN_COUNT Step 1
         
         Call body.BeginInsert( rtNav )
         Call body.AppendText( columnHeader(col) )   ' Write the text for this column's header
         Call body.EndInsert                              ' Move insertion point to the end of this cell
         Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )   ' Move to the next cell
      Next
      
   Else          '!!!  wird immer nächste Tabelle erstellt

        '!!! Findet letzte Tablecell-Element im Navigator
      Call rtNav.FindLastElement(RTELEM_TYPE_TABLECELL)
      Call rtNav.GetLastElement(RTELEM_TYPE_TABLE)             '!!! Geht zu letzter Tabelle
      Set rtTable= rtNav.GetElement
      
       '!!! Findet nächste Tablecell-Element im Navigator, d. h. erste Tablecell-Element in der letzte Tabelle
      Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )
      
      rtTable.Style = TABLESTYLE_TOP
      Set color = session.CreateColorObject         ' Create color object for use in setting cell colors
      color.NotesColor = COLOR_LIGHT_GRAY
      Call rtTable.SetColor( color )         ' Set the top row color to light gray background
      color.NotesColor = COLOR_WHITE
      Call rtTable.SetAlternateColor( color )      ' Set all rows after the top row to white background
      
      Call body.AppendStyle( rtHelv8_Black_Bold  )      ' Set the font to Helvetica, 8-point, bold black
      For col = 1 To COLUMN_COUNT Step 1
         
         Call body.BeginInsert( rtNav )
         Call body.AppendText( columnHeader(col) )   ' Write the text for this column's header
         Call body.EndInsert                              ' Move insertion point to the end of this cell
         Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )   ' Move to the next cell
      Next
   End If
   

End Function

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz