2

我想使用 Outlook 2010、Windows 7 和 IE8 发送电子邮件,获取“Outlook.Application”对象需要什么代码?

我尝试使用 CreateObject("Outlook.Application") 但收到错误“需要对象”

4

4 回答 4

1

示例代码:-

' Create email object
  Set oolApp = CreateObject("Outlook.Application")
  Set email = oolApp.CreateItem(0)
  email.Recipients.Add("abcaashn@gmail.com")

  ' Create the body of the email
  MailBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD W3 HTML//EN"">"
  MailBody = MailBody & "<HTML>" & vbcrlf
  MailBody = MailBody & "<HEAD><TITLE>No Invoices</TITLE></HEAD>"
  MailBody = MailBody & "<BODY>" & vbcrlf
  MailBody = MailBody & "<B>For Your Information</B>,<BR><BR>"
  MailBody = MailBody & "This is Sample Email.<BR><BR>"
  MailBody = MailBody & "</BODY></HTML>"

  ' Send the Email
  email.Subject = "No Invoices Issued"
  email.HTMLBody = MailBody
  email.Send
于 2012-02-22T12:56:37.827 回答
1

试试这个简单的代码。

这将帮助您打开 Outlook 并将您导航到收件箱

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
objNamespace.Logon "Default Outlook Profile", , False, True
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
objFolder.Display
End Sub
于 2015-12-23T06:35:28.547 回答
0

您可以使用 Outlook 使用的子系统 CDO 发送电子邮件。您可以在我的文章在 ASP Free 上的 WSH 中使用 CDO 发送电子邮件中找到更多信息。

Set objMessage = CreateObject("CDO.Message")

' Set Email Headers
objMessage.From = "sender@mymail.com"
objMessage.To = "abcaashn@gmail.com"
objMessage.Subject = "No Invoices Issued"

' Construct Email Body
objMessage.HTMLbody = "<b>For Your Information</b>, <br><br>" _
                    & "This is a Sample Email.<br><br>"

objMessage.AutoGenerateTextBody = True

' Set Server Settings
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mymail.com"
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objEmail.Configuration.Fields.Update
objEmail.Send
于 2012-02-22T19:58:10.860 回答
0

这对我有用:-

Public Sub runOutlook
 Set oolApp = CreateObject("Outlook.Application")
 Set objNS = oolApp.GetNamespace("MAPI")
 Set email = oolApp.CreateItem(0)
 email.Display
 email.To = "yash.tiwari@programmers.io"
 email.Subject = "Test"
 email.HTMLbody = "<b>For Your Information</b>, <br><br>" _
                    & "This is a Sample Email.<br><br>"              
 email.GetInspector.WindowState = 2             
End Sub
于 2020-09-24T11:55:39.580 回答