Hello every one 
I'm trying to send email using VBA code, the function is working and the email is sent, but the problem is when function end 'Run-time error 438 object doesn't support this property or method' appears
here is the code:
I'm trying to send email using VBA code, the function is working and the email is sent, but the problem is when function end 'Run-time error 438 object doesn't support this property or method' appears
here is the code:
Code:
Public Function SendEmail(ItemName As String, Total_Qnty As Integer)
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' send one copy with Google SMTP server (with autentication)
schema = "schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpserver") = "smtp.gmail.com"
Flds.Item(schema & "smtpserverport") = 465
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = "[EMAIL="example@gmail.com"]example@gmail.com[/EMAIL]"
Flds.Item(schema & "sendpassword") = "*****"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "[EMAIL="example@hotmail.com"]example@hotmail.com[/EMAIL]"
.From = "[EMAIL="example@gmail.com"]example@gmail.com[/EMAIL]"
.Subject = "Mail from gmail"
.HTMLBody = "The Stock Safty Level of Item: " & ItemName & " is DOWN, The total quantity you have is: " & Total_Qnty & "!!"
Set .Configuration = iConf
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
End Function
Last edited by a moderator: