0

VBA コードを使用して電子メールを送信しようとしています。関数は動作しており、電子メールは送信されますが、問題は、関数の終了時に「実行時エラー 438 オブジェクトはこのプロパティまたはメソッドをサポートしていません」と表示されることです。

コードは次のとおりです。

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 = "http://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") = "example@gmail.com"

 Flds.Item(schema & "sendpassword") = "*****"

 Flds.Item(schema & "smtpusessl") = 1

 Flds.Update


 With iMsg

     .To = "example@hotmail.com"

     .From = "example@gmail.com"

     .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

任意のアイデアを喜ば..ありがとう

4

2 に答える 2

0

これらの順序を逆にします。

Set iMsg = Nothing

Set iConf = Nothing

Set Flds = Nothing

Fldsは iConf のメンバーですが、現在、あなたは既に破棄しています。

于 2013-07-30T15:00:55.287 に答える