VBA via Lotus Notes 8
Bonjour,
J'ai mis en place une macro qui me permet d'écrire un message dans Lotus Notes.
Tout fonctionne parfaitement MAIS quand le texte s'insère il se met après ma signature électronique ... savez vous comment je peux faire pour inscrire ce texte au dessus ?
Merci d'avance pour vos réponses
cdt,
Bonsoir,
peux-tu nous montrer à quoi ressemble ta macro ? peux-tu nous mettre ton fichier ?
Voili, Voilou,
Sub Mail()
Dim Session As Object
Dim Dir As Object
Dim Doc As Object
Dim Workspace As Object
Dim EditDoc As Object
For Lig = 2 To Feuil3.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row
'Création de la session Notes
Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Set Session = CreateObject("notes.NOTESSESSION")
Set Dir = Session.GETDATABASE("", "")
Call Dir.OPENMAIL
'Creation d'un document
Set Doc = Dir.CREATEDOCUMENT
If Feuil1.Range("AF" & Lig) = ""
And Now - 30 > Range("B" & Lig)
And Range("K" & Lig) <> "Gagnée"
And Range("K" & Lig) <> "Perdue"
And Range("K" & Lig) <> "Abandonnée" Then
With OutMail
Doc.Subject = "Relance opportunité " & Feuil3.Range("D" & Lig).Text
Doc.SendTo = Feuil3.Range("N" & Lig).Text
Doc.SendCopyTo = "Christian@nsp.Fr, "; Feuil3.Range("C" & Lig).Text
‘Doc.sendBCC = ""
Doc.Body = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & Feuil3.Range("D" & Lig).Text & " est toujours au statut » & Feuil3.Range("K" & Lig).Text &, « peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? "
& vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf &
Call Workspace.EditDocument(True, Doc, False, , False, True)
Feuil3.Range("AF" & Lig) = Date
End With
End If
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Next Lig
End Sub
Bonsoir,
J'ai vu quelques erreurs de syntaxe et des instructions qui me semblent inutiles, voici une proposition de correction (sans filet, car je n'ai pas la possibilité de tester, ne disposant pas de lotus notes).
Sub Mail()
Dim Session As Object
Dim Dir As Object
Dim Doc As Object
Dim Workspace As Object
Dim EditDoc As Object
'Création de la session Notes
Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Set Session = CreateObject("notes.NOTESSESSION")
Set Dir = Session.GETDATABASE("", "")
Call Dir.OPENMAIL
For Lig = 2 To Feuil3.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row
'Création de la session Notes
'Creation d'un document
Set Doc = Dir.CREATEDOCUMENT
If Feuil1.Range("AF" & Lig) = "" _
And Now - 30 > Range("B" & Lig) _
And Range("K" & Lig) <> "Gagnée" _
And Range("K" & Lig) <> "Perdue" _
And Range("K" & Lig) <> "Abandonnée" Then
Doc.Subject = "Relance opportunité " & Feuil3.Range("D" & Lig).Text
Doc.SendTo = Feuil3.Range("N" & Lig).Text
Doc.SendCopyTo = "Christian@nsp.Fr, "; Feuil3.Range("C" & Lig).Text
Doc.Body = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & Feuil3.Range("D" & Lig).Text & " est toujours au statut » & Feuil3.Range("K" & Lig).Text &, « peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? "
& vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf &
Call Workspace.EditDocument(True, Doc, False, , False, True)
Feuil3.Range("AF" & Lig) = Date
set doc=nothing
End If
Next Lig
Set Dir = nothing
Set Session = nothing
Set Workspace =nothing
End Sub
Merci c'est vraiment gentil ! Concernant mon probleme de signature électronique qui est générée avec la création du mail et donc mise avant le texte , avez vous une solution ?
Cdt
Bonsoir,
la documentation notes indique que pour récupérer la signature par défaut il faut utiliser NUIWorkspace
sur base d'un code trouvé sur internet à cette adresse http://www.mrexcel.com/forum/excel-questions/684890-visual-basic-applications-code-lotus-notes-email-preparation-excel-worksheet.html, j'ai adapté ta macro.
A nouveau je travaille sans filet, n'ayant aucune possibilité de tester quoi que ce soit.
Public Sub Send_Notes_Email()
Dim NSession As Object
Dim NUIWorkspace As Object
Dim NMailDb As Object
Dim NUIDocument As Object
Dim bodytext As String
Set NSession = CreateObject("Notes.NotesSession") 'OLE (late binding only) because we access Notes UI classes
Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set NMailDb = NSession.GETDATABASE("", "")
NMailDb.OPENMAIL
'Compose the email document
For lig = 2 To Feuil3.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row
If Feuil1.Range("AF" & lig) = "" And Now - 30 > Range("B" & lig) And Range("K" & lig) <> "Gagnée" And Range("K" & lig) <> "Perdue" And Range("K" & lig) <> "Abandonnée" Then
Set NUIDocument = NUIWorkspace.ComposeDocument(NMailDb.Server, NMailDb.filePath, "Memo")
'Set NUIDocument = NUIWorkspace.ComposeDocument(, , "Memo") 'use local computer and current database
With NUIDocument
.Fieldsettext "EnterSendTo", Feuil3.Range("N" & lig).Text
.Fieldsettext "EnterCopyTo", "Christian@nsp.Fr, " & Feuil3.Range("C" & lig).Text
.Fieldsettext "Subject", "Relance opportunité " & Feuil3.Range("D" & lig).Text
bodytext = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & Feuil3.Range("D" & lig).Text & " est toujours au statut " & Feuil3.Range("K" & lig).Text & ",peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? " _
& vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf
.Fieldsettext "Body", bodytext
'Set NotesDocument options to save and send the email without prompts when the Close method is called
.Document.SaveOptions = "1"
.Document.MailOptions = "1"
.Close
End With
Set NUIDocument = Nothing
End If
Next lig
End SubDonc sur le principe ma signature va arriver après le texte ??? En tout c'est vraiment sympa ça fait une semaine que je farfouille partout et que je ne vois rien ... Bon j'essaye ca demain et je vous tiens au courant !!!! Et encore merci !
h2so4 a écrit :Bonsoir,
la documentation notes indique que pour récupérer la signature par défaut il faut utiliser NUIWorkspace
sur base d'un code trouvé sur internet à cette adresse http://www.mrexcel.com/forum/excel-questions/684890-visual-basic-applications-code-lotus-notes-email-preparation-excel-worksheet.html, j'ai adapté ta macro.
A nouveau je travaille sans filet, n'ayant aucune possibilité de tester quoi que ce soit.
Public Sub Send_Notes_Email() Dim NSession As Object Dim NUIWorkspace As Object Dim NMailDb As Object Dim NUIDocument As Object Dim bodytext As String Set NSession = CreateObject("Notes.NotesSession") 'OLE (late binding only) because we access Notes UI classes Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace") Set NMailDb = NSession.GETDATABASE("", "") NMailDb.OPENMAIL 'Compose the email document For lig = 2 To Feuil3.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row If Feuil1.Range("AF" & lig) = "" And Now - 30 > Range("B" & lig) And Range("K" & lig) <> "Gagnée" And Range("K" & lig) <> "Perdue" And Range("K" & lig) <> "Abandonnée" Then Set NUIDocument = NUIWorkspace.ComposeDocument(NMailDb.Server, NMailDb.filePath, "Memo") 'Set NUIDocument = NUIWorkspace.ComposeDocument(, , "Memo") 'use local computer and current database With NUIDocument .Fieldsettext "EnterSendTo", Feuil3.Range("N" & lig).Text .Fieldsettext "EnterCopyTo", "Christian@nsp.Fr, " & Feuil3.Range("C" & lig).Text .Fieldsettext "Subject", "Relance opportunité " & Feuil3.Range("D" & lig).Text bodytext = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & Feuil3.Range("D" & lig).Text & " est toujours au statut " & Feuil3.Range("K" & lig).Text & ",peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? " _ & vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf .Fieldsettext "Body", bodytext 'Set NotesDocument options to save and send the email without prompts when the Close method is called .Document.SaveOptions = "1" .Document.MailOptions = "1" .Close End With Set NUIDocument = Nothing End If Next lig End Sub
Bonsoir, je viens aux nouvelles
Donc votre code fonctionne très bien !! Et je vous remercie sincèrement pour votre aide.
Donc ce code supprime la signature et donc je n'en bénéficie plus ce qui cela dit n'est pas gênant pour ce que je souhaite faire. Mise à part si vous avez une autre solution je suis preneur !
Par contre j'aurais besoin de votre aide à nouveau si vous le voulez bien
J'aimerais que cette macro s'applique sur toutes les pages de mon classeur à partir de la troisième est ce que possible ? si oui comment puis je l' adapter ?
En tout cas si vous n'avez pas la réponse je vous remercie encore du temps que vous m'avez accordé.
Bien cordialement
Donc ce code supprime la signature et donc je n'en bénéficie plus ce qui cela dit n'est pas gênant pour ce que je souhaite faire. Mise à part si vous avez une autre solution je suis preneur !
comme tu l'auras compris, je t'ai fait ce code sur base des infos que j'ai trouvées sur internet. Sur base de ces infos, la signature aurait dû être récupérée. Je comprends que cela n'est pas le cas, je n'ai pas d'autre solution.
Par contre j'aurais besoin de votre aide à nouveau si vous le voulez bien
J'aimerais que cette macro s'applique sur toutes les pages de mon classeur à partir de la troisième est ce que possible ? si oui comment puis je l' adapter ?
là il faudra m'en dire un peu plus, sans fichier et sans autre explication, je ne comprends absolument pas la demande.
Pour être plus précis, ce qui reste difficile après une journée exténuante
Le fichier comporte les demandes des conseillers et il est mis en forme de la façon suivante : (pièce jointe en +)
Feuille 1 (Cumul) Represente un tableau reprenant l'activité des CC (conseillers) cette feuille n'est pas utile pour la macro
Feuille 2 (Dispatch) Represente des demandes qui sont transmises aux CC de mon équipe cette feuille n'est pas utile pour la macro
A PARTIR DE LA FEUILLE 3 jusqu'à la dernière (évolutif au fil du temps)
Chaque feuille est une feuille individuelle qui recense les demandes créés par les conseillers et c'est sur ces feuilles que je souhaite intervenir avec mes relances.
J'espère être plus clair sinon faut me le dire et je vais happer mon chocolat chaud pour me détendre
Et encore mes plus sincères remerciements
Bonsoir,
essaie ceci.
Public Sub Send_Notes_Email()
Dim NSession As Object
Dim NUIWorkspace As Object
Dim NMailDb As Object
Dim NUIDocument As Object
Dim bodytext As String
Set NSession = CreateObject("Notes.NotesSession") 'OLE (late binding only) because we access Notes UI classes
Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set NMailDb = NSession.GETDATABASE("", "")
NMailDb.OPENMAIL
For Each ws In Worksheets
If ws.name <> "CUMUL" And ws.name <> "DISPATCH" Then
'Compose the email document
For lig = 2 To ws.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row
If Feuil1.Range("AF" & lig) = "" And Now - 30 > Range("B" & lig) And Range("K" & lig) <> "Gagnée" And Range("K" & lig) <> "Perdue" And Range("K" & lig) <> "Abandonnée" Then
Set NUIDocument = NUIWorkspace.ComposeDocument(NMailDb.Server, NMailDb.filePath, "Memo")
'Set NUIDocument = NUIWorkspace.ComposeDocument(, , "Memo") 'use local computer and current database
With NUIDocument
.Fieldsettext "EnterSendTo", ws.Range("N" & lig).Text
.Fieldsettext "EnterCopyTo", "Christian@nsp.Fr, " & ws.Range("C" & lig).Text
.Fieldsettext "Subject", "Relance opportunité " & ws.Range("D" & lig).Text
bodytext = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & ws.Range("D" & lig).Text & " est toujours au statut " & ws.Range("K" & lig).Text & ",peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? " _
& vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf
.Fieldsettext "Body", bodytext
'Set NotesDocument options to save and send the email without prompts when the Close method is called
.Document.SaveOptions = "1"
.Document.MailOptions = "1"
.Close
End With
Set NUIDocument = Nothing
End If
Next lig
End If
Next
End Subedit : correction du code
Super merci beaucoup ! J'essaye ca demain et on se dit ce que ça donne ...
Bonne soirée
re-Bonsoir,
j'ai fait une correction dans le code précédent.
Bonjour,
Alors j'ai un petit problème avec le code : il ne tiens pas compte des la ligne suivante :
If ws.Range("AF" & Lig) = "" And Now - 30 > Range("B" & Lig) And Range("K" & Lig) <> "Gagnée" And Range("K" & Lig) <> "Perdue" And Range("K" & Lig) <> "Abandonnée" Then
Voici le code que j'ai mis :
Sub Mail()
Dim NSession As Object
Dim NUIWorkspace As Object
Dim NMailDb As Object
Dim NUIDocument As Object
Dim bodytext As String
Set NSession = CreateObject("Notes.NotesSession") 'OLE (late binding only) because we access Notes UI classes
Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set NMailDb = NSession.GETDATABASE("", "")
NMailDb.OPENMAIL
For Each ws In Worksheets
If ws.Name <> "Dispatch portefeuille Chamb" Then
'Compose the email document
For Lig = 2 To ws.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row
If ws.Range("AF" & Lig) = "" And Now - 30 > Range("B" & Lig) And Range("K" & Lig) <> "Gagnée" And Range("K" & Lig) <> "Perdue" And Range("K" & Lig) <> "Abandonnée" Then
Set NUIDocument = NUIWorkspace.ComposeDocument(NMailDb.Server, NMailDb.filePath, "Memo")
'Set NUIDocument = NUIWorkspace.ComposeDocument(, , "Memo") 'use local computer and current database
With NUIDocument
.Fieldsettext "EnterSendTo", ws.Range("N" & Lig).Text
.Fieldsettext "EnterCopyTo", "Christian@nsp.Fr, " & "antoine.p@nsp.fr, " & ws.Range("C" & Lig).Text
.Fieldsettext "Subject", "Relance opportunité " & ws.Range("D" & Lig).Text
bodytext = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & ws.Range("D" & Lig).Text & " est toujours au statut " & ws.Range("K" & Lig).Text & ", peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? " & vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement," & vbCrLf & vbCrLf & "Antoine" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf
.Fieldsettext "Body", bodytext
'Set NotesDocument options to save and send the email without prompts when the Close method is called
.Document.SaveOptions = "1"
.Document.MailOptions = "1"
ws.Range("AF" & Lig) = Date
.Close
End With
Set NUIDocument = Nothing
End If
Next Lig
End If
Next
End SubBonjour,
proposition de correction, mais tu n'en dis pas beaucoup sur le problème ...
Sub Mail()
Dim NSession As Object
Dim NUIWorkspace As Object
Dim NMailDb As Object
Dim NUIDocument As Object
Dim bodytext As String
Set NSession = CreateObject("Notes.NotesSession") 'OLE (late binding only) because we access Notes UI classes
Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set NMailDb = NSession.GETDATABASE("", "")
NMailDb.OPENMAIL
For Each ws In Worksheets
If ws.Name <> "Dispatch portefeuille Chamb" Then
'Compose the email document
For Lig = 2 To ws.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row
If ws.Range("AF" & Lig) = "" And Now - 30 > ws.Range("B" & Lig) And ws.Range("K" & Lig) <> "Gagnée" And ws.Range("K" & Lig) <> "Perdue" And ws.Range("K" & Lig) <> "Abandonnée" Then
Set NUIDocument = NUIWorkspace.ComposeDocument(NMailDb.Server, NMailDb.filePath, "Memo")
'Set NUIDocument = NUIWorkspace.ComposeDocument(, , "Memo") 'use local computer and current database
With NUIDocument
.Fieldsettext "EnterSendTo", ws.Range("N" & Lig).Text
.Fieldsettext "EnterCopyTo", "Christian@nsp.Fr, " & "antoine.p@nsp.fr, " & ws.Range("C" & Lig).Text
.Fieldsettext "Subject", "Relance opportunité " & ws.Range("D" & Lig).Text
bodytext = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & ws.Range("D" & Lig).Text & " est toujours au statut " & ws.Range("K" & Lig).Text & ", peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? " & vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement," & vbCrLf & vbCrLf & "Antoine" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf
.Fieldsettext "Body", bodytext
'Set NotesDocument options to save and send the email without prompts when the Close method is called
.Document.SaveOptions = "1"
.Document.MailOptions = "1"
ws.Range("AF" & Lig) = Date
.Close
End With
Set NUIDocument = Nothing
End If
Next Lig
End If
Next
End SubPour info le débogage me met cette phrase en jaune : Set NUIDocument = NUIWorkspace.ComposeDocument(NMailDb.Server, NMailDb.filePath, "Memo")
Alors j'ai fait plusieurs essais, le code fonctionne bien lorsque j'ai une page, par contre quand je commence à en avoir deux cela me met le code erreur (image jointe)
Je pense que c'est du a la rapidité de la macro et que lotus ne suit pas ... est-il possible que la macro fasse une boucle avant de lancer le mail suivant ?
Deuxième hypothèse : Le changement de page ne lui convient pas !
bonsoir,
ajout d'une instruction d'attente de 10 secondes.
Sub Mail()
Dim NSession As Object
Dim NUIWorkspace As Object
Dim NMailDb As Object
Dim NUIDocument As Object
Dim bodytext As String
Set NSession = CreateObject("Notes.NotesSession") 'OLE (late binding only) because we access Notes UI classes
Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set NMailDb = NSession.GETDATABASE("", "")
NMailDb.OPENMAIL
For Each ws In Worksheets
If ws.Name <> "Dispatch portefeuille Chamb" Then
'Compose the email document
For Lig = 2 To ws.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row
If ws.Range("AF" & Lig) = "" And Now - 30 > ws.Range("B" & Lig) And ws.Range("K" & Lig) <> "Gagnée" And ws.Range("K" & Lig) <> "Perdue" And ws.Range("K" & Lig) <> "Abandonnée" Then
Set NUIDocument = NUIWorkspace.ComposeDocument(NMailDb.Server, NMailDb.filePath, "Memo")
Application.Wait(Now + TimeValue("0:00:10")) ' attendre 10 secondes
'Set NUIDocument = NUIWorkspace.ComposeDocument(, , "Memo") 'use local computer and current database
With NUIDocument
.Fieldsettext "EnterSendTo", ws.Range("N" & Lig).Text
.Fieldsettext "EnterCopyTo", "Christian@nsp.Fr, " & "antoine.p@nsp.fr, " & ws.Range("C" & Lig).Text
.Fieldsettext "Subject", "Relance opportunité " & ws.Range("D" & Lig).Text
bodytext = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & ws.Range("D" & Lig).Text & " est toujours au statut " & ws.Range("K" & Lig).Text & ", peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? " & vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement," & vbCrLf & vbCrLf & "Antoine" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf
.Fieldsettext "Body", bodytext
'Set NotesDocument options to save and send the email without prompts when the Close method is called
.Document.SaveOptions = "1"
.Document.MailOptions = "1"
ws.Range("AF" & Lig) = Date
.Close
End With
Set NUIDocument = Nothing
End If
Next Lig
End If
Next
End SubMerci beaucoup je vous dit ca demain !
En tout cas merci mille fois.
Bonne soiree
Bonsoir,
pour le cas où l'ajout du wait ne fonctionnerait pas, voici une autre possibilité.
Sub Mail()
Dim NSession As Object
Dim NUIWorkspace As Object
Dim NMailDb As Object
Dim NUIDocument As Object
Dim bodytext As String
For Each ws In Worksheets
If ws.Name <> "Dispatch portefeuille Chamb" Then
'Compose the email document
For Lig = 2 To ws.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Row
If ws.Range("AF" & Lig) = "" And Now - 30 > ws.Range("B" & Lig) And ws.Range("K" & Lig) <> "Gagnée" And ws.Range("K" & Lig) <> "Perdue" And ws.Range("K" & Lig) <> "Abandonnée" Then
Set NSession = CreateObject("Notes.NotesSession") 'OLE (late binding only) because we access Notes UI classes
Set NUIWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set NMailDb = NSession.GETDATABASE("", "")
NMailDb.OPENMAIL
Set NUIDocument = NUIWorkspace.ComposeDocument(NMailDb.Server, NMailDb.filePath, "Memo")
'Application.Wait (Now + TimeValue("0:00:10")) ' attendre 10 secondes
'Set NUIDocument = NUIWorkspace.ComposeDocument(, , "Memo") 'use local computer and current database
With NUIDocument
.Fieldsettext "EnterSendTo", ws.Range("N" & Lig).Text
.Fieldsettext "EnterCopyTo", "Christian@nsp.Fr, " & "antoine.p@nsp.fr, " & ws.Range("C" & Lig).Text
.Fieldsettext "Subject", "Relance opportunité " & ws.Range("D" & Lig).Text
bodytext = "Bonjour, " & vbCrLf & vbCrLf & "L'opportunité " & ws.Range("D" & Lig).Text & " est toujours au statut " & ws.Range("K" & Lig).Text & ", peux tu me dire si elle a été traitée ou si tu es en attente d'une réponse du client ? " & vbCrLf & vbCrLf & "Merci d'avance" & vbCrLf & vbCrLf & "Je reste à ta disposition pour de plus amples informations." & vbCrLf & vbCrLf & "Bien Cordialement," & vbCrLf & vbCrLf & "Antoine" & vbCrLf & vbCrLf & " Cet e-mail est généré automatiquement car la date de l'opportunité a dépassé 30 jours." & vbCrLf & vbCrLf
.Fieldsettext "Body", bodytext
'Set NotesDocument options to save and send the email without prompts when the Close method is called
.Document.SaveOptions = "1"
.Document.MailOptions = "1"
ws.Range("AF" & Lig) = Date
.Close
End With
Set NUIDocument = Nothing
Set NUIWorkspace = Nothing
Set NMailDb = Nothing
End If
Next Lig
End If
Next
End SubD'accord, j'essaye ça demain (j'espère avoir le temps je suis en réunion toute la journée et après en weekend et de nouveau des réunions la semaine prochaine) en tout cas je ne vous remercierais jamais assez car je sais que ça prend du temps et que c'est par pur sympathie ? ou par plaisir ? que vous faite ça ! en tout cas c'est vraiment génial !!!!