Tienes razón, pediste que sea por gmail. Te anexo la macro, cambia "hoja1" por la hoja a enviar, "[email protected]" y "pwd" pos los datos de tu gmail.
Sub EnviarHoja()
'Por.Dante Amor
hoja = "Hoja1"
correo = "[email protected]"
passwd = "pwd"
dest = Sheets(hoja).[K11]
'
Application.DisplayAlerts = False
Application.ScreenUpdating = False
ruta = ThisWorkbook.Path & "\"
nombre = Sheets(hoja).Name
Sheets(hoja).Copy
ActiveWorkbook.SaveAs Filename:=ruta & nombre & ".xlsx"
ActiveWorkbook.Close False
'
Dim Email As CDO.Message
'
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 = dest
.From = correo
.Subject = "Planilla Electrónica"
'.TextBody = "Cuerpo del coreo"
.AddAttachment ruta & nombre & ".xlsx"
.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