Bonsoir,
J'ai besoin d'aide. Cette macro fonctionne très bien mais je souhaiterai envoyer toujours l'attachement par contre supprimer la sauvegarde du fichier sur C.
Avez vous une idée ?
Merci, d'avance
A+
Sub E()
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 NomFichier As String
'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"
Recipient = Split(Range("A1").Value, ",")
MailDoc.Sendto = Recipient
'MailDoc.CopyTo = ""
MailDoc.Subject = "XXX"
'MailDoc.Body = "XXXX"
MailDoc.SAVEMESSAGEONSEND = saveit
Set objNotesField = MailDoc.CreateRichTextItem("Body")
With objNotesField
.AppendText ""
.AddNewLine 1
End With
'Partie à modifier
NomFichier = "C:\X\X" & Format(Now, "dd.mm.yyyy,hh""h""mm") & ".xls"
Sheets("DEMANDE D'INTERVENTION").Copy
ActiveWorkbook.SaveCopyAs Filename:="C:\X\X" & Format(Now, "dd.mm.yyyy,hh""h""mm") & ".xls"
ActiveWorkbook.Close False
Set AttachME = MailDoc.CreateRichTextItem("Attachment")
Set EmbedObj = AttachME.EmbedObject(1454, "", "C:\X\X" & Format(Now, "dd.mm.yyyy,hh""h""mm") & ".xls", "Attachment")
'Fin de modif
'Envoi du document
Call MailDoc.Send(False)
prvSendNotesMail = True
GoTo ExitHandle
ErrHandle:
MsgBox Err.Description
prvSendNotesMail = False
ExitHandle:
'Vidage mémoire
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set oSession = Nothing
Set dbDirectory = Nothing
Set EmbedObj = Nothing
End Sub
J'ai besoin d'aide. Cette macro fonctionne très bien mais je souhaiterai envoyer toujours l'attachement par contre supprimer la sauvegarde du fichier sur C.
Avez vous une idée ?
Merci, d'avance
A+
Sub E()
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 NomFichier As String
'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"
Recipient = Split(Range("A1").Value, ",")
MailDoc.Sendto = Recipient
'MailDoc.CopyTo = ""
MailDoc.Subject = "XXX"
'MailDoc.Body = "XXXX"
MailDoc.SAVEMESSAGEONSEND = saveit
Set objNotesField = MailDoc.CreateRichTextItem("Body")
With objNotesField
.AppendText ""
.AddNewLine 1
End With
'Partie à modifier
NomFichier = "C:\X\X" & Format(Now, "dd.mm.yyyy,hh""h""mm") & ".xls"
Sheets("DEMANDE D'INTERVENTION").Copy
ActiveWorkbook.SaveCopyAs Filename:="C:\X\X" & Format(Now, "dd.mm.yyyy,hh""h""mm") & ".xls"
ActiveWorkbook.Close False
Set AttachME = MailDoc.CreateRichTextItem("Attachment")
Set EmbedObj = AttachME.EmbedObject(1454, "", "C:\X\X" & Format(Now, "dd.mm.yyyy,hh""h""mm") & ".xls", "Attachment")
'Fin de modif
'Envoi du document
Call MailDoc.Send(False)
prvSendNotesMail = True
GoTo ExitHandle
ErrHandle:
MsgBox Err.Description
prvSendNotesMail = False
ExitHandle:
'Vidage mémoire
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set oSession = Nothing
Set dbDirectory = Nothing
Set EmbedObj = Nothing
End Sub