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
|
Private Sub CommandButton1_Click()
'Bouton ENVOYER
cellmax = Sheets(1).Cells(12666, 1).End(xlUp).Row
Sheets(1).Cells(1, 11).Value = "Statut Mail :"
For j = 2 To cellmax
Label6.Caption = "Traitement de la " & j & "ème lignes sur les " & cellmax & " !!!"
On Error GoTo TraiteErreur
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim attachme As Object 'The attachment richtextfile object
Dim session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim attachment
attachment = lefichier
Set session = CreateObject("Notes.NotesSession")
'Open the mail database in notes
Set Maildb = session.GETDATABASE("", "NOM.nsf")
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.openmail
End If
'Set up the new mail document
Set MailDoc = Maildb.createdocument
MailDoc.form = "Memo"
MailDoc.from = "MAIL.FR"
MailDoc.Principal = "MAIL.FR"
MailDoc.Subject = "OBJET"
MailDoc.body = "CORPS"
MailDoc.ReplyTo = "MAIL.fr"
MailDoc.SaveMessageOnSend = True
'& vbCrLf &
'PJ
If attachment <> "" Then
Set attachme = MailDoc.CreateRichTextItem("Attachment")
Set EmbedObj = attachme.EMBEDOBJECT(1454, "", attachment, "Attachment")
End If
'Send the document
MailDoc.posteddate = Now()
MailDoc.SEND 1, "" & adrmail
Set Maildb = Nothing
Set MailDoc = Nothing
Set attachme = Nothing
Set session = Nothing
Set EmbedObj = Nothing
Sheets(3).Cells(ligneStats, 6).Value = Sheets(3).Cells(ligneStats, 6).Value + 1
Sheets(1).Cells(j, 11).Value = "Envoyé !!!"
GoTo passeCeJ
TraiteErreur:
Sheets(3).Cells(ligneStats, 5).Value = Sheets(3).Cells(ligneStats, 5).Value + 1
Sheets(1).Cells(j, 11).Value = "Erreur !!!"
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set attachme = Nothing
Set session = Nothing
Set EmbedObj = Nothing
passeCeJ:
Next j
Unload Me
End Sub |
Partager