0
在VB6項目,這個代碼工作使用了Microsoft Office Outlook 15.0對象庫通過Outlook 2013發送電子郵件:的CreateObject不類模塊工作(Visual Basic 6中)
Private Sub Command1_Click()
Dim objOutlook As Outlook.Application
Set objOutlook = CreateObject("Outlook.Application")
Dim mail As Outlook.MailItem
Set mail = objOutlook.CreateItem(olMailItem)
mail.To = txt_Recipient
mail.Subject = txt_Subject
mail.body = txt_Inhalt.Text
mail.Send
當現在我試圖將相同的代碼轉移到類模塊中,它不斷拋出錯誤429,無法在第三行創建對象。任何想法爲什麼它不能在類模塊中工作,而在Command_Click事件中直接進行編碼?
代碼的類:
Public objOutlook As outlook.Application
Public Sub MailSenden(ByVal empfaenger As String, ByVal betreff As String, ByVal inhalt As String)
Set objOutlook = CreateObject("Outlook.Application")
Dim mail As outlook.MailItem
Set mail = objOutlook.CreateItem(olMailItem)
mail.To = empfaenger
mail.Subject = betreff
mail.body = inhalt
mail.Send
End Sub
感謝任何幫助,您可以給我! Colin