helios_foster
New Member
Hi there,
I´m using a code that is not working properly. The purpose is to send several emails attaching a pdf doc. Can anyone help me to find out a solution?:
Sub Sendmail()
For i = CInt(Range("B6")) To CInt(Range("B7"))
Dim Email As CDO.Message
Set Email = New CDO.Message
my_email = Range("B2")
password_my_email = Sheets("Pass").Range("C2")
recipient_mails = Range("B" & CStr(i))
copied_mail = Range("B3")
c_c_d = Range("B4")
subject = Range("C" & CStr(i))
Persona = Range("A" & CStr(i))
Message = Range("A10")
sign = Range("C10")
Email.Configuration.Fields(cdoSMTPServer) = "smtp.gmail.com"
Email.Configuration.Fields(cdoSendUsingMethod) = 2
With Email.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = CLng(465)
.Item("http://schemas.microsoft.com/cdo/" & "configuration/smtpauthenticate") = Abs(1)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = my_email
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Pass
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
End With
With Email
.To = recipient_mails
.From = my_emails
.Subject = "School" & " - " & Matter & " / " & "Families"
.TextBody = "Dear families," & vbCrLf & vbCrLf & Mensaje & vbCrLf & vbCrLf & sign
.Configuration.Fields.Update
If (Trim(copied_mail) = "") Then
.CC = copied_mail
End If
.AddAttachment (Range("B4").Value
On Error Resume Next
.Send
End With
Next
If Err.Number = 0 Then
MsgBox "Sent email", vbInformation, "Resumen"
Else
MsgBox "Error: " & Err.Description, vbCritical, "Error"
End If
I´m using a code that is not working properly. The purpose is to send several emails attaching a pdf doc. Can anyone help me to find out a solution?:
Sub Sendmail()
For i = CInt(Range("B6")) To CInt(Range("B7"))
Dim Email As CDO.Message
Set Email = New CDO.Message
my_email = Range("B2")
password_my_email = Sheets("Pass").Range("C2")
recipient_mails = Range("B" & CStr(i))
copied_mail = Range("B3")
c_c_d = Range("B4")
subject = Range("C" & CStr(i))
Persona = Range("A" & CStr(i))
Message = Range("A10")
sign = Range("C10")
Email.Configuration.Fields(cdoSMTPServer) = "smtp.gmail.com"
Email.Configuration.Fields(cdoSendUsingMethod) = 2
With Email.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = CLng(465)
.Item("http://schemas.microsoft.com/cdo/" & "configuration/smtpauthenticate") = Abs(1)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = my_email
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Pass
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
End With
With Email
.To = recipient_mails
.From = my_emails
.Subject = "School" & " - " & Matter & " / " & "Families"
.TextBody = "Dear families," & vbCrLf & vbCrLf & Mensaje & vbCrLf & vbCrLf & sign
.Configuration.Fields.Update
If (Trim(copied_mail) = "") Then
.CC = copied_mail
End If
.AddAttachment (Range("B4").Value
On Error Resume Next
.Send
End With
Next
If Err.Number = 0 Then
MsgBox "Sent email", vbInformation, "Resumen"
Else
MsgBox "Error: " & Err.Description, vbCritical, "Error"
End If