H o l a:
Pon la siguiente macro dentro del formulario o dentro de tu commandbutton
Sub EnviarArchivo()
'Por.Dante Amor
Application.DisplayAlerts = False
Application.ScreenUpdating = False
ruta = ThisWorkbook.Path & "\"
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ruta & "archivo.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
'
Dim Email As CDO.Message
'
correo = "[email protected]"
passwd = "pwd"
'
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") = correo
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = passwd
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
End With
With Email
.To = "[email protected]; [email protected]"
.From = correo
.Subject = "asunto de mensaje"
.TextBody = "Cuerpo del coreo"
.AddAttachment ruta & "archivo.pdf"
.Configuration.Fields.Update
On Error Resume Next
.Send
End With
If Err.Number = 0 Then
MsgBox "El mail se envió con éxito"
Else
MsgBox "Se produjo el siguiente error: " & Err.Number & " " & Err.Description
End If
Set Email = Nothing
End Sub
Tienes que actualizar lo siguiente en la macro:
- correo = "[email protected]", por tu correo de gmail
- passwd = "pwd", por tu password de gmail
- .To = "[email protected]; [email protected]", por los destinatarios
- .Subject = "asunto de mensaje", por el asunto del correo
.TextBody = "Cuerpo del coreo", por el texto del cuerpo del correo