Private Sub SendEmail(strEmail, strEpass, strSendTo, strSubject, strTextBody , Optional strAttachment As String) Dim objCDOMsg As New CDO.Message Dim objCDOCon As New CDO.Configuration Dim strSchemas As String strSchemas = "http://schemas.microsoft.com/cdo/configuration/" With objCDOCon.Fields .Item(strSchemas & "sendusing") = 2 .Item(strSchemas & "smtpserver") = "smtp.gmail.com" .Item(strSchemas & "smtpserverport") = 465 .Item(strSchemas & "smtpauthenticate") = 1 .Item(strSchemas & "sendusername") = strEmail ' Your gmail .Item(strSchemas & "sendpassword") = strEpass ' Your password .Item(strSchemas & "smtpconnectiontimeout") = 30 .Item(strSchemas & "smtpusessl") = 1 .Update End With ' Construct your email With objCDOMsg .From = strEmail ' Your Email .To = strSendTo ' Send to any email (example: example@yahoo.com) .Subject = strSubject ' Subject .TextBody = strTextBody ' Body .Sender = strEmail ' Your Email .ReplyTo = strEmail ' Your Email .AddAttachment strAttachment ' Your Attachment Set .Configuration = objCDOCon .Send ' Send Email End With End Sub