1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Public Function OvhMail(strTo As String, strSubject As String, strContent As String) As Boolean
Dim objEmail As Object
On Error GoTo errLabel
Set objEmail = CreateObject("CDO.Message")
With objEmail.Configuration.Fields
.Item(CdoConfiguration.cdoSendUsingMethod) = 2
.Item(CdoConfiguration.cdoSMTPAuthenticate) = 1
.Item(CdoConfiguration.cdoSendUserName) = "TonAdresse@ovh.xxx"
.Item(CdoConfiguration.cdoSendPassword) = "Ton Password OVH"
.Item(CdoConfiguration.cdoSMTPServer) = "ns0.ovh.net"
.Item(CdoConfiguration.cdoSMTPServerPort) = 587
.Update
End With
With objEmail
.To = strTo
.Subject = strSubject
.textbody = strContent
.AddAttachment ThisWorkbook.FullName
.Send
OvhMail = True
End With
Set objEmail = Nothing
Exit Function
errLabel:
MsgBox Err.Description
OvhMail = False
Set objEmail = Nothing
End Function |