Sub SendNotesMail()
If Day(Date) > 5 Then: MsgBox "Le fichier à déjà été envoié", , "Excel-Downloads": Exit Sub
If Day(Date) = 5 Then
'Set up the objects required for Automation into lotus notes
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)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GetDatabase("", MailDbName)
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.Sendto = "la tu mets l'adresse mail de ton correspondant" '(laisse les "")
MailDoc.CopyTo = "l'adresse de la personne en copie" '(laisse les "")
MailDoc.Subject = "la tu mets le sujet" '(avec des "")
' Construction du corps du message
Set objNotesField = MailDoc.CreateRichTextItem("Body")
With objNotesField
.AppendText "Bonjour,"
.AddNewLine 2
.AppendText "Ci-joint la situation." 'tu peux réjouter des lignes
.AddNewLine 2
.AppendText "Cordialement"
.AddNewLine 1
.AppendText "Martin DUPONT"
.AddNewLine 3
End With
MailDoc.SaveMessageOnSend = SaveIt
'Set up the embedded object and attachment and attach it
Attachment1 = "la tu mets le chemin d'acces complet de ton fichier excel.xls"
Attachment2 = "idem 2e fichier"
Attachment3 = "idem 3e ficher"
If Attachment1 <> "" And Attachment2 <> "" And Attachment3 <> "" Then
Set AttachME = MailDoc.CreateRichTextItem("Attachment1")
Set EmbedObj = AttachME.EmbedObject(1454, "", Attachment1, "Attachment1")
MailDoc.CreateRichTextItem (Attachment1)
Set AttachME = MailDoc.CreateRichTextItem("Attachment2")
Set EmbedObj = AttachME.EmbedObject(1454, "", Attachment2, "Attachment2")
MailDoc.CreateRichTextItem (Attachment2)
Set AttachME = MailDoc.CreateRichTextItem("Attachment3")
Set EmbedObj = AttachME.EmbedObject(1454, "", Attachment3, "Attachment3")
MailDoc.CreateRichTextItem (Attachment3)
End If
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End If
End Sub