Escolar Documentos
Profissional Documentos
Cultura Documentos
Macro para Enviar Un Email Automatico
Macro para Enviar Un Email Automatico
correo_origen = "eltiotechperu@gmail.com"
Clave_correo_origen = "Mamani@123,"
'MsgBox (numerodatos)
'correo_copia = "micorreocopia@gmail.com"
'correo_copia_oculta = "copiaoculta@gmail.com"
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/smtpconnectiontimeout")
= 30
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
correo_origen
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
Clave_correo_origen
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
End With
With Email
.To = correo_destino
.From = correo_origen
.Subject = Asunto
.TextBody = Mensaje
.Configuration.Fields.Update
.CC = correo_copia
End If
.AddAttachment (adjunto)
.Send
End With
If Err.Number = 0 Then
MsgBox "El correo se fue enviado con éxito", vbInformation, "Resumen"
Else
End If
End If
Next
End Sub
Sub Envio1()
correo_origen = "eltiotechperu@gmail.com"
Clave_correo_origen = "Mamani@123,"
correo_destino = Range("i6").Value
Asunto = Range("L6")
Mensaje = Range("I12")
'correo_copia = "envioacorreocopia@gmail.com"
'correo_copia_oculta = "enviocopiaoculta@gmail.com"
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/smtpconnectiontimeout") = 30
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = correo_origen
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
Clave_correo_origen
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
End With
With Email
.To = correo_destino
.From = correo_origen
.Subject = Asunto
.TextBody = Mensaje
.Configuration.Fields.Update
.CC = correo_copia
End If
.AddAttachment (Range("L8").Value)
.Send
End With
If Err.Number = 0 Then
Else
End If
End Sub