目前,我正在尝试使用 VB.NET 发送电子邮件。现在,我添加了这段代码的引用:(我添加了占位符)
Module Module1
Sub Main()
' Create an Outlook application.
Dim oApp As Outlook._Application
oApp = New Outlook.Application()
' Create a new MailItem.
Dim oMsg As Outlook._MailItem
oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oMsg.Subject = "Send Attachment Using OOM in Visual Basic .NET"
oMsg.Body = "Hello World" & vbCr & vbCr
' TODO: Replace with a valid e-mail address.
oMsg.To = "user@example.com"
' Add an attachment
' TODO: Replace with a valid attachment path.
Dim sSource As String = "C:\Temp\Hello.txt"
' TODO: Replace with attachment name
Dim sDisplayName As String = "Hello.txt"
Dim sBodyLen As String = oMsg.Body.Length
Dim oAttachs As Outlook.Attachments = oMsg.Attachments
Dim oAttach As Outlook.Attachment
oAttach = oAttachs.Add(sSource, , sBodyLen + 1, sDisplayName)
' Send
oMsg.Send()
' Clean up
oApp = Nothing
oMsg = Nothing
oAttach = Nothing
oAttachs = Nothing
End Sub
End Module
对于所有 Outlook 项目(Outlook.Application、Outlook._MailItem、Outlook、Outlook.Attachments、Outlook.Attachment)未声明或未定义,我如何才能使引用正常工作。
提前致谢。