I am able to send emails through GMAIL using this:
Expand|Select|Wrap|Line Numbers
- Private Sub Email_Invoice_Click()
- On Error GoTo errHandler
- DoCmd.SetWarnings False
- If IsNull(Forms![mainProcessEntry]![UserEmail]) Then
- MsgBox "Please enter your email address"
- DoCmd.OpenForm "mainprocessentry"
- Forms![mainProcessEntry]![UserEmail].SetFocus
- Exit Sub
- End If
- Dim strpath As String
- Dim stDocName As String
- Dim mypath As String
- Dim objCDO As New CDO.Message
- Dim objBP As CDO.IBodyPart
- strpath = "C:\Invoices\"
- mypath = strpath & "invoice.pdf"
- Debug.Print mypath
- Me.invoicepath = mypath
- MyFileName = mypath
- emailfile = CStr(mypath & ".pdf")
- stDocName = "rptinvoice"
- DoCmd.OutputTo acReport, stDocName, acFormatPDF, mypath, False
- Dim msg As Object
- Set msg = CreateObject("CDO.Message")
- msg.From = Forms![mainProcessEntry]![UserEmail]
- msg.to = [Forms]![mainProcessEntry]![invoiceemail1]
- Debug.Print msg.to
- msg.Subject = "Your Invoice is Attached"
- msg.textbody = "Thank you!"
- msg.CC = ""
- msg.BCC = ""
- msg.ReplyTo = strMailFrom
- msg.AddAttachment "c:\invoices\invoice.pdf"
- msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
- msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
- msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
- msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Forms![mainProcessEntry]![UserEmail]
- msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Forms![mainProcessEntry]![Password]
- msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
- msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
- msg.Configuration.Fields.Update
- msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""3"" color=""black""><b>Quantum Process, LLC</b></font><BR>"
- msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""blue"">"
- msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""black"">418 Pittman Rd.</font><BR>"
- msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""black"">Ellisville, MS 39437</font><BR>"
- msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""black"">(601) 319-2675 office</font><BR>"
- msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""black"">(877) 852-9532 fax</font><BR>"
- msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""blue""><b><BR>http://www.QuantumProcess.com</b></font><BR>"
- msg.HTMLBody = msg.HTMLBody & Forms![mainProcessEntry]![UserEmail]
- msg.HTMLBody = msg.HTMLBody & "<font face=""Arial"" size=""2"" color=""green""><u>" & SW & "</u></font><BR>"
- msg.HTMLBody = msg.HTMLBody & "<font face=""Arial"" size=""2"" color=""blue"">"
- msg.HTMLBody = msg.HTMLBody & "<img src='C:\Clients\Quantum Process Keith Investigations\paymentbutton.png' height=57 width=192><br>"
- msg.Send
- Exit Sub
- errHandler:
- MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
- VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
- End Sub