Accueil > > > AIDE SUR L'AUTOMATION LOTUS NOTES SOUS VB
AIDE SUR L'AUTOMATION LOTUS NOTES SOUS VB
Information sur la source
Description
Bonjour à tous
Voici une aide vraiment bien détaillée pour tous ceux qui veulent utiliser Lotus Notes dans leur application VB et qui n'y arrivent pas...ça arrive des fois !!!!;)
Je vous met le lien vers cette page car le document (900ko en pdf) est trop gros pour aller sur ce site
ftp://ftp.boulder.ibm.com/software/lotus/p ub/lotusweb/ssdev/lsvbrb.pdf
Bon code à tous
SeHN
Source
- Option Explicit
- '---------- API -----------
- 'pour faire passer au premier plan
- Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
- 'pour ouvrir la fenetre
- Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
- 'pour verifier si la Lotus est ouvert
- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
-
- Dim sSrvr As String 'the mail server for the current user
- Dim MailDbName As String 'THe current users notes mail database name
- Dim UserName As String 'The current users notes name
-
- Dim retval As Variant 'Holds return value for functions handle
-
- '---------------- fonction ouverture de session Notes -----------
- Function CreateNotesSession() As Boolean
- Const notesclass$ = "NOTES"
- Const SW_SHOWMAXIMIZED = 3 'plein ecran
- Const SW_SHOWMMINIZED = 2 'reduire
- Const SW_SHOWWINDOW = 1 'fenetre
- Const SW_SHOW = 5
-
- Dim Lotus_Session As Object
- Dim rc&
- Dim lotusWindow&
-
- lotusWindow = FindWindow(notesclass, vbNullString)
-
- Set Lotus_Session = CreateObject("Notes.NotesSession")
- sSrvr = Lotus_Session.GETENVIRONMENTSTRING("MailServer", True)
- MailDbName = Lotus_Session.GETENVIRONMENTSTRING("MailFile", True)
- UserName = Lotus_Session.UserName
-
- DoEvents
- 'Ouverture de Lotus Notes
- retval = Shell("C:\APPLI\Notes5\notes.exe =h:\notes\notes.ini", vbMaximizedFocus)
-
- 'verifier que Lotus est bien ouvert (recupere le handle)
- lotusWindow = FindWindow(notesclass, vbNullString)
- If lotusWindow <> 0 Then
- rc = ShowWindow(lotusWindow, SW_SHOW)
- rc = SetForegroundWindow(lotusWindow)
- CreateNotesSession = True
- Else
- CreateNotesSession = False
- End If
- End Function
- Sub CreateMailandAttachFileAdr(Optional IsSubject As String = "", Optional SendToAdr As String, Optional CCToAdr As String, Optional BCCToAdr As String = "", Optional Attach1 As String = "", Optional Attach2 As String = "", Optional body As String = "")
- Const EMBED_ATTACHMENT As Integer = 1454
- Const EMBED_OBJECT As Integer = 1453
- Const EMBED_OBJECTLINK As Integer = 1452
-
- Dim s As Object ' use back end classes to obtain mail database name
- Dim db As Object '
- Dim doc As Object ' front end document
- Dim beDoc As Object ' back end document
- Dim workspace As Object ' use front end classes to display to user
- Dim bodypart As Object '
- Dim bodyAtt As Object '
- Dim lbsession As Boolean
-
- lbsession = CreateNotesSession
-
- If lbsession Then
- 'cree la session Lotus Notes
- Set s = CreateObject("Notes.Notessession")
- 'se connecte a sa database
- Set db = s.getDatabase(sSrvr, MailDbName)
- If db.ISOPEN = True Then
- 'database deja ouvert
- Else
- Call db.Openmail
- End If
- 'cree un document memo
- Set beDoc = db.CreateDocument
- beDoc.Form = "Memo"
-
- 'construction du mail
- Set bodypart = beDoc.CREATERICHTEXTITEM("Body")
- 'beDoc.From = "Moi" 'inutile
- beDoc.SendTo = SendToAdr
- beDoc.CopyTo = CCToAdr
- beDoc.BlindCopyTo = BCCToAdr
- beDoc.Subject = IsSubject
- '-----------------------------------------
- 'Remarque si destinataire multiple il suffie de mettre un tableau d'e-mail dans SendTo (CopyTo,BlindCopyTo)
- 'exemple :
- 'Dim recip(25) as variant
- 'recip(0) = "emailaddress1"
- 'recip(1) = "emailaddress2" e.t.c
- 'beDoc.sendto = recip
- '----------------------------------------
- ' documents joint 1
- If Len(Attach1) > 0 Then
- If Len(Dir(Attach1)) > 0 Then
- Set bodyAtt = bodypart.EmbedObject(EMBED_ATTACHMENT, "", Attach1, Dir(Attach1))
- End If
- End If
-
- ' documents joint 2
- If Len(Attach2) > 0 Then
- If Len(Dir(Attach2)) > 0 Then
- Call bodyAtt.EmbedObject(EMBED_ATTACHMENT, "", Attach2, Dir(Attach2))
- End If
- End If
-
- 'Affichage du mail dans Lotus Notes
- Set workspace = CreateObject("Notes.NotesUIWorkspace")
- Call workspace.EditDocument(True, beDoc).FieldSetText("Body", body)
-
- Set s = Nothing
- Else
- MsgBox "Votre Lotus Notes est fermé !"
- End If
- End Sub
- Private Sub envoyer_Click()
- CreateMailandAttachFileAdr Msujet.Text, Mto.Text, Mcc.Text, Mbcc.Text, MdocJoint1.Text, MdocJoint2.Text, Mbody.Text
- End Sub
Option Explicit
'---------- API -----------
'pour faire passer au premier plan
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
'pour ouvrir la fenetre
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
'pour verifier si la Lotus est ouvert
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim sSrvr As String 'the mail server for the current user
Dim MailDbName As String 'THe current users notes mail database name
Dim UserName As String 'The current users notes name
Dim retval As Variant 'Holds return value for functions handle
'---------------- fonction ouverture de session Notes -----------
Function CreateNotesSession() As Boolean
Const notesclass$ = "NOTES"
Const SW_SHOWMAXIMIZED = 3 'plein ecran
Const SW_SHOWMMINIZED = 2 'reduire
Const SW_SHOWWINDOW = 1 'fenetre
Const SW_SHOW = 5
Dim Lotus_Session As Object
Dim rc&
Dim lotusWindow&
lotusWindow = FindWindow(notesclass, vbNullString)
Set Lotus_Session = CreateObject("Notes.NotesSession")
sSrvr = Lotus_Session.GETENVIRONMENTSTRING("MailServer", True)
MailDbName = Lotus_Session.GETENVIRONMENTSTRING("MailFile", True)
UserName = Lotus_Session.UserName
DoEvents
'Ouverture de Lotus Notes
retval = Shell("C:\APPLI\Notes5\notes.exe =h:\notes\notes.ini", vbMaximizedFocus)
'verifier que Lotus est bien ouvert (recupere le handle)
lotusWindow = FindWindow(notesclass, vbNullString)
If lotusWindow <> 0 Then
rc = ShowWindow(lotusWindow, SW_SHOW)
rc = SetForegroundWindow(lotusWindow)
CreateNotesSession = True
Else
CreateNotesSession = False
End If
End Function
Sub CreateMailandAttachFileAdr(Optional IsSubject As String = "", Optional SendToAdr As String, Optional CCToAdr As String, Optional BCCToAdr As String = "", Optional Attach1 As String = "", Optional Attach2 As String = "", Optional body As String = "")
Const EMBED_ATTACHMENT As Integer = 1454
Const EMBED_OBJECT As Integer = 1453
Const EMBED_OBJECTLINK As Integer = 1452
Dim s As Object ' use back end classes to obtain mail database name
Dim db As Object '
Dim doc As Object ' front end document
Dim beDoc As Object ' back end document
Dim workspace As Object ' use front end classes to display to user
Dim bodypart As Object '
Dim bodyAtt As Object '
Dim lbsession As Boolean
lbsession = CreateNotesSession
If lbsession Then
'cree la session Lotus Notes
Set s = CreateObject("Notes.Notessession")
'se connecte a sa database
Set db = s.getDatabase(sSrvr, MailDbName)
If db.ISOPEN = True Then
'database deja ouvert
Else
Call db.Openmail
End If
'cree un document memo
Set beDoc = db.CreateDocument
beDoc.Form = "Memo"
'construction du mail
Set bodypart = beDoc.CREATERICHTEXTITEM("Body")
'beDoc.From = "Moi" 'inutile
beDoc.SendTo = SendToAdr
beDoc.CopyTo = CCToAdr
beDoc.BlindCopyTo = BCCToAdr
beDoc.Subject = IsSubject
'-----------------------------------------
'Remarque si destinataire multiple il suffie de mettre un tableau d'e-mail dans SendTo (CopyTo,BlindCopyTo)
'exemple :
'Dim recip(25) as variant
'recip(0) = "emailaddress1"
'recip(1) = "emailaddress2" e.t.c
'beDoc.sendto = recip
'----------------------------------------
' documents joint 1
If Len(Attach1) > 0 Then
If Len(Dir(Attach1)) > 0 Then
Set bodyAtt = bodypart.EmbedObject(EMBED_ATTACHMENT, "", Attach1, Dir(Attach1))
End If
End If
' documents joint 2
If Len(Attach2) > 0 Then
If Len(Dir(Attach2)) > 0 Then
Call bodyAtt.EmbedObject(EMBED_ATTACHMENT, "", Attach2, Dir(Attach2))
End If
End If
'Affichage du mail dans Lotus Notes
Set workspace = CreateObject("Notes.NotesUIWorkspace")
Call workspace.EditDocument(True, beDoc).FieldSetText("Body", body)
Set s = Nothing
Else
MsgBox "Votre Lotus Notes est fermé !"
End If
End Sub
Private Sub envoyer_Click()
CreateMailandAttachFileAdr Msujet.Text, Mto.Text, Mcc.Text, Mbcc.Text, MdocJoint1.Text, MdocJoint2.Text, Mbody.Text
End Sub
Conclusion
Historique
- 18 novembre 2004 20:07:31 :
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
VB.NET ET COMBOBOXVB.NET ET COMBOBOX par minouthebreaker
Cliquez pour lire la suite par minouthebreaker
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|