Hello,

For my company i am busy to automate the invoice system. The main goal is:
- to convert a brochure to a invoice (done)
- The next thing is to make sure the invoicenumbers keep ascending (done)/ Save the invoice as pdf file(done)
- Send the specific invoice to the customer through Gmail
The last is the thing i cant get done.

I already know how to send a new message by Gmail with a text by clicking a button in Excel but the problem is i am stuck at sending the specific invoice to the customer.

Is there a way to choose a file to attach to the mail or is there a way to send the current worksheet(invoice) and at the same time save this invoice on the pc as pdf?

i am pretty new with vba so i dont know what to do anymore

Sub send_email_via_Gmail()

Dim myMail As CDO.Message

Set myMail = New CDO.Message

' i deleted the Http :// in the following rules because i could not post links because this is my first post

myMail.Configuration.Fields.Item("schemas.microsoft. com/cdo/configuration/smtpusessl") = True

myMail.Configuration.Fields.Item("schemas.microsoft. com/cdo/configuration/smtpauthenticate") = 1

myMail.Configuration.Fields.Item("schemas.microsoft. com/cdo/configuration/smtpserver") = "smtp.gmail"

myMail.Configuration.Fields.Item("schemas.microsoft. com/cdo/configuration/smtpserverport") = 25

myMail.Configuration.Fields.Item("schemas.microsoft. com/cdo/configuration/sendusing") = 2

myMail.Configuration.Fields.Item("schemas.microsoft. com/cdo/configuration/sendusername") = "company mail adres"

myMail.Configuration.Fields.Item("schemas.microsoft. com/cdo/configuration/sendpassword") = "password"

myMail.Configuration.Fields.Update

With myMail
.Subject = "Test Email from eisse"
.From = """company name"" <company mail adres>"
.To = "my mail adress"
.CC = ""
.BCC = ""
.HTMLBody = the text to put in the mail
.AddAttachment "C:/users/eisse/desktop/invoice 3.pdf"
End With
On Error Resume Next
myMail.Send
'MsgBox("Mail has been sent")
Set myMail = Nothing

End Sub