Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Question sur l'envoi des mails (MS Access vers MS Outlook )

1 réponse
Avatar
TF
Bonsoir,
Quand j'ai un publipostage à faire, pour chaque message envoyé je trouve
dans le Gestionnaire des tâches de Windows XP Pro, une instance de MS
Outlook, pourquoi MS Outlook reste charger dans la mémoire ?
Estce que mon code lui manque une commande pour fermer MS Outlook ?

Merci

Voilà le code VBA utilisé :

Function SendMail(Sujet, Message, Nom, Prenom, Email, DateEnvoi, Optional
Fichier)
Dim outl As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim NewEmail As Outlook.MailItem

Set ns = outl.GetNamespace("MAPI")
Set NewEmail = outl.CreateItem(olMailItem)
NewEmail.Subject = Sujet
NewEmail.Body = Message
With NewEmail.Recipients.Add(Email)
.Type = olTo
End With

' Envoyer un fichier avec l'EMAIL
If Not IsMissing(Fichier) Then
If Len(Fichier) Then
With NewEmail.Attachments.Add(Fichier)
.DisplayName = Fichier
End With
End If
End If

NewEmail.Send
Set ns = Nothing
Set outl = Nothing
outl.Quit
Set NewEmail = Nothing
End Function

1 réponse

Avatar
Raymond [mvp]
Bonsoir.

Set outl = Nothing
outl.Quit
Tu supprimes l'objet outlook avant de quitter outlook, donc pas de quit.
le quit n'est pas obligatoire avec outlook, le nothing fermant l'objet
application.
supprime le quit.
place le Set outl = Nothing en dernière position.
--
@+
Raymond Access MVP
http://OfficeSystem.Access.free.fr/
http://www.mpfa.info/ pour débuter sur le forum.
l'abonnement TechNet !
http://www.microsoft.com/france/technet/presentation/cd/default.mspx


"TF" a écrit dans le message de news:
441f0a0b$0$19022$
Bonsoir,
Quand j'ai un publipostage à faire, pour chaque message envoyé je trouve
dans le Gestionnaire des tâches de Windows XP Pro, une instance de MS
Outlook, pourquoi MS Outlook reste charger dans la mémoire ?
Estce que mon code lui manque une commande pour fermer MS Outlook ?

Merci

Voilà le code VBA utilisé :

Function SendMail(Sujet, Message, Nom, Prenom, Email, DateEnvoi, Optional
Fichier)
Dim outl As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim NewEmail As Outlook.MailItem

Set ns = outl.GetNamespace("MAPI")
Set NewEmail = outl.CreateItem(olMailItem)
NewEmail.Subject = Sujet
NewEmail.Body = Message
With NewEmail.Recipients.Add(Email)
.Type = olTo
End With

' Envoyer un fichier avec l'EMAIL
If Not IsMissing(Fichier) Then
If Len(Fichier) Then
With NewEmail.Attachments.Add(Fichier)
.DisplayName = Fichier
End With
End If
End If

NewEmail.Send
Set ns = Nothing
Set outl = Nothing
outl.Quit
Set NewEmail = Nothing
End Function