Hello,
First of all my best wishes to you all and thank you for your continued relevance aid.
I started the year as I left. Pb mail access
In the following code, I debug a problem with the CurrentDb.OpenRecordset
First of all my best wishes to you all and thank you for your continued relevance aid.
I started the year as I left. Pb mail access
In the following code, I debug a problem with the CurrentDb.OpenRecordset
Code:
' ---
' ENVOYER UN MAIL DEPUIS ACCESS
' ---
' Entrée : strEmail <- Adresse e-mail du destinataire
' strObj <- Objet du courrier
' strMsg <- Corps du message
' blnEdit <- True pour pouvoir modifier le courrier avant envoi
' False pour expédier le courrier directement.
'
Public Sub SendMail(ByVal strEmail As String, _
ByVal strObj As String, _
ByVal strMsg As String, _
ByVal blnEdit As Boolean)
'On Error Resume Next
DoCmd.SendObject acSendNoObject, , , strEmail, , , strObj, strMsg, blnEdit
End Sub
Private Sub Outlook_Click()
Dim MonOutlook As New Outlook.Application
Dim MonMessage As Outlook.MailItem
Dim ListeEMail As Recordset
Dim ListeComplete As String
' Initialisation
Set MonMessage = MonOutlook.CreateItem(0)
[COLOR=Red] Set ListeEMail = CurrentDb.OpenRecordset("SELECT e-mail FROM demandes 2007")[/COLOR]
'
ListeEMail.MoveFirst
ListeComplete = ""
' Parcourt des enregistrements de la requête
While Not ListeEMail.EOF
ListeComplete = ListeComplete & ListeEMail("e-Mail") & ";"
MonMessage.Attachments.Add ListeEMail(" ")
ListeEMail.MoveNext
Wend
'Remplissage de l'objet MailItem
MonMessage.To = e - mail
MonMessage.BCC = Left(ListeComplete, Len(ListeComplete) - 1) ' On enlève le dernier point virgule
MonMessage.Subject = Id
MonMessage.Body = prenom & vbCrLf
' Envoi du mail
MonMessage.Display
' Fermeture de la session Outlook et désallocation des objets
MonOutlook.Quit
ListeEMail.Close
Set MonOutlook = Nothing
Set ListeEMail = Nothing
End Sub