JohannR
Messages postés7Date d'inscriptionvendredi 28 août 2009StatutMembreDernière intervention14 septembre 2009
-
28 août 2009 à 19:04
JohannR
Messages postés7Date d'inscriptionvendredi 28 août 2009StatutMembreDernière intervention14 septembre 2009
-
7 sept. 2009 à 11:59
Bonjour à toutes et à tous,
je ne sais si j'ai précisement affecté ce post au bon endroit, et je m'excuse par avance d'une erreur eventuelle
Je suis débutant sur VBA et malgré toutes mes recherches je ne peux envoyer un mail type à tout les destinataires d'une colonnes par pression d'un bouton de commande. Par ailleurs je precise que le nombre et l'identité des destinataires evolue sans cesse.
J'utilise actuellement le code suivant :
Par l'intermediare de Box, il me permet de selectionner une adresse mail et de spécifier le sujet de mon memo. La pièce jointe vient ensuite s'y rattacher avant de procéder à l'envoi (avec acc. de reception).
Sub Object414_Click()
Dim oItem As Object
Dim stSubject As Variant
Dim vaRecipient As Variant, vaMsg As Variant
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean
Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler
'Building Message
Do
vaRecipient = Application.InputBox( _
Prompt:="Veuillez saisir un destinataire.", _
Title:="Recipient", Type:=2)
Loop While vaRecipient = ""
'If the user has canceled the operation.
If vaRecipient = False Then Exit Sub
'Get the message from the user.
Do
stSubject = Application.InputBox( _
Prompt:="Veuillez préciser le sujet de votre envoi.", _
Title:="Subject", Type:=2)
Loop While stSubject = ""
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = stSubject
oDoc.sendto = vaRecipient
oDoc.ReturnReceipt = "1"
oDoc.postdate = Date
With oItem
.AppendText "bonne réception,"
.AddNewLine 1
.AppendText "Cordialement"
End With
'Attaching DATABASE
Call oItem.EmbedObject(1454, "", "C:\Documents and Settings\Administrator\Desktop\mon doc.txt")
oDoc.visable = True
oDoc.SaveMessageOnSend = True
'Sending Message
oDoc.SEND False
AppActivate "Microsoft Excel"
MsgBox "Votre email a été envoyé avec succès", vbInformation
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "la pièce jointe est introuvable, vérifiez le chemin d'accès"
Else
MsgBox Err.Number & " " & Err.Description
End If
MsgBox "Message non envoyé suite erreur!", vbCritical
On Error GoTo exit_SendAttachment
End Sub
Je vous remercie pour tte l'aide que vous voudrez bien m'apporter,
cdlt,