Hi vds1,
That's what I did... still not working. Here is the code:
____________________________________________________
Private Sub btnSendEmail_Click()
Dim MAIL As New Message
Dim config As Configuration
Set config = MAIL.Configuration
Set MAIL = CreateObject("CDO.Message")
config(cdoSendUsingMethod) = cdoSendUsingPort
config(cdoSMTPServer) = "smtp.gmail.com"
config(cdoSMTPServerPort) = 25
config(cdoSMTPAuthenticate) = cdoBasic
config(cdoSMTPUseSSL) = True
config(cdoSendUserName) = "email@email.com"
config(cdoSendPassword) = "password"
config.Fields.Update
Call createJpg("MAILDELAY.FR", "A1:I49", "INVOICE")
tempfilepath = Environ$("temp") & "\"
MAIL.AddAttachment tempfilepath & "INVOICE.jpg", olbyvalue, 1
MAIL.To = Range("N14").Text
MAIL.CC = Range("N15").Text
MAIL.From = config(cdoSendUserName)
MAIL.Subject = "Pénalité " + Range("E17").Text + " sur délai de livraison // " + Range("N4").Text
MAIL.HTMLBody = "<span LANG=FR><p class=style2 p align=justify p style='width='850' height='1500'><span LANG=FR><font FACE=Calibri SIZE=3>" & _
"<p>dear, blah blah blah...<p/>"
MAIL.AddAttachment Sheets("MAILDELAY.FR").Range("N17").Value
On Error Resume Next
MAIL.Send
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "There was an error"
Exit Sub
End If
MsgBox "your email has been sent", vbInformation, "sent"
End Sub
_______________________________________________________
Sub createJpg(Namesheet As String, nameRange As String, nameFile As String)
ThisWorkbook.Activate
Worksheets(Namesheet).Activate
Set Plage = ThisWorkbook.Worksheets(Namesheet).Range(nameRange)
Plage.CopyPicture
With ThisWorkbook.Worksheets(Namesheet).ChartObjects.Add(Plage.Left, Plage.Top, Plage.Width, Plage.Height)
.Activate
.Chart.Paste
.Chart.Export Environ$("temp") & "\" & nameFile & ".jpg", "JPG"
End With
Worksheets(Namesheet).ChartObjects(Worksheets(Namesheet).ChartObjects.Count).Delete
Set Plage = Nothing
End Sub