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
|
Sub EnvoyerReponseCartoParMail(ObjetDuMail, MessageDuMail, AdresseMail)
Dim ObjNotesSession As Object
Dim ObjNotesMailFile As Object
Dim ObjNotesDocument As Object
Dim ObjNotesField As Object
Dim SendMail As Boolean
Dim Msg As String
Dim EMailCCTo As String
Dim EMailBCCTo As String
' Mpfe, auteur inconnu
On Error GoTo SendMailError
On Error Resume Next
EMailCCTo = "" '' Optional
EMailBCCTo = "" '' Optional
' Etablissement de la connection à Notes
Set ObjNotesSession = CreateObject("Notes.NotesSession")
' Establish Connection to Mail File
' .GETDATABASE("SERVER", "FILE")
Set ObjNotesMailFile = ObjNotesSession.GETDATABASE("", "")
'Ouverture du Mail
ObjNotesMailFile.OPENMAIL
'Création d'un nouveau mémo
Set ObjNotesDocument = ObjNotesMailFile.CREATEDOCUMENT
'Create 'Subject Field'
Set ObjNotesField = ObjNotesDocument.APPENDITEMVALUE("Subject", ObjetDuMail)
'Create 'Send To' Field
Set ObjNotesField = ObjNotesDocument.APPENDITEMVALUE("SendTo", AdresseMail)
' Adresser en copie
On Error Resume Next
Set ObjNotesField = ObjNotesDocument.APPENDITEMVALUE("CopyTo", EMailCCTo)
' Adresser en copie cachée
Set ObjNotesField = ObjNotesDocument.APPENDITEMVALUE("BlindCopyTo", EMailBCCTo)
' Corps du message
Set ObjNotesField = ObjNotesDocument.CREATERICHTEXTITEM("Body")
With ObjNotesField
.APPENDTEXT MessageDuMail
End With
' Attacher le fichier --1454 indique un attachement de fichier
ObjNotesField = ObjNotesField.EMBEDOBJECT(1454, "", ActiveWorkbook.FullName)
' Envoi de l'email
ObjNotesDocument.SEND (0)
'Release storage
Set ObjNotesSession = Nothing
Set ObjNotesMailFile = Nothing
Set ObjNotesDocument = Nothing
Set ObjNotesField = Nothing
'Set return code
SendMail = True
Exit Sub
SendMailError:
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
SendMail = False
End Sub |
Partager