barandaran
New Member
- Joined
- Apr 12, 2018
- Messages
- 3
Hello people of the forum.
Using one of the many models on the web for sending emails using CDO, I'm creating a macro, with attachments, to a list of people.
Everything works Caaasi Well, because sends the emails, but presents the problem that repeats the file attached.
That is to say, when using a FOR loop: The first mail sends you 1 attachment, but then the second sends 2, to third 3 and so on.
I put the object variable = Nothing but it does not recognize it. This is the part of the code with problem
If someone has had the same problem, please.
:
Dim Email As CDO. Message
Set Email = CreateObject ( "CDO. Message ")
.
.
For I = 6 To Range ( "E " & Rows. Count). End (xlUp). Row
With Email. Configuration. Fields
.
.
.
.
End With
.
.
With Email
. To = cells (I, "E ")
. From = Mail
. Subject = "Visit Notice "
FormaNum = cells (I, "D ")
. TextBody = "visit notice " & Format (FormaNum, "#, # # #, # # #. 00 ") & "Cancel appointment before " & Cells (3, "E ")
. AddAttachment cells (28, "c ") ' Cells (28, "c ") Path PDF file
. AddAttachment (RUTAANEXO1)
' . Attachments. Add Range ( "C28 "). Value ' produces error missmacth
' . Attachment. Delete
' . Send
' Email = Nothing ' does not recognize nothing. Not cleaning the attaches? He repeats them
' If Not Email Is Nothing Then
' Set Email = Nothing
' End If
End With
Next
.
.
.
.
Using one of the many models on the web for sending emails using CDO, I'm creating a macro, with attachments, to a list of people.
Everything works Caaasi Well, because sends the emails, but presents the problem that repeats the file attached.
That is to say, when using a FOR loop: The first mail sends you 1 attachment, but then the second sends 2, to third 3 and so on.
I put the object variable = Nothing but it does not recognize it. This is the part of the code with problem
If someone has had the same problem, please.
:
Dim Email As CDO. Message
Set Email = CreateObject ( "CDO. Message ")
.
.
For I = 6 To Range ( "E " & Rows. Count). End (xlUp). Row
With Email. Configuration. Fields
.
.
.
.
End With
.
.
With Email
. To = cells (I, "E ")
. From = Mail
. Subject = "Visit Notice "
FormaNum = cells (I, "D ")
. TextBody = "visit notice " & Format (FormaNum, "#, # # #, # # #. 00 ") & "Cancel appointment before " & Cells (3, "E ")
. AddAttachment cells (28, "c ") ' Cells (28, "c ") Path PDF file
. AddAttachment (RUTAANEXO1)
' . Attachments. Add Range ( "C28 "). Value ' produces error missmacth
' . Attachment. Delete
' . Send
' Email = Nothing ' does not recognize nothing. Not cleaning the attaches? He repeats them
' If Not Email Is Nothing Then
' Set Email = Nothing
' End If
End With
Next
.
.
.
.