Error no se ha definido el tipo definido por el usuario

Tengo este código de una macro en excel

Sub SendMail_Gmail()
'Mod.Por.DAM
Dim Email As CDO.Message
correo = "[email protected]"
passwd = "pwd"
For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
Set Email = New CDO.Message
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") = "[email protected]"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "pwd"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
End With
With Email
.To = Cells(i, "A")
.From = correo
.Subject = Cells(i, "B")
.TextBody = Cells(i, "C")
.AddAttachment Cells(i, "E") & Cells(i, "D")
.Configuration.Fields.Update
On Error Resume Next
.Send
End With
If Err.Number = 0 Then
Cells(i, "F") = "El mail se envió con éxito"
Else
Cells(i, "F") = "Se produjo el siguiente error: " & Err.Number & " " & Err.Description
End If
Set Email = Nothing
Next
End Sub

Pero al intentarlo correr me manda este error: "error no se ha definido el tipo definido por el usuario"

Podrían ayudarme y decirme donde esta o porque es este error

1 Respuesta

Respuesta
1

Lo más seguro es que tengas problemas ya que no has habilitado las referencias, te dejo un par de códigos de envío de mail que funcionan, ese seguramente funciona porque veo que lo hizo DAM.

https://youtu.be/JhRwXdyLVIE

https://youtu.be/sTJK_zm8nOM

https://youtu.be/XhRJxrHKYzQ

https://youtu.be/GyD0kKU_RJw

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas