通过vbscript打开outlook 2010

时间:2012-02-22 09:08:14

标签: vbscript outlook.application

我想使用outlook 2010,Windows 7和&amp ;;发送电子邮件。 IE8,获取“Outlook.Application”对象所需的代码是什么?。

我试过了 CreateObject(“Outlook.Application”)但收到错误“Object Required”

4 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

您可以使用CDO发送电子邮件,CDO是Outlook使用的子系统。您可以在我的文章Sending Emails Using CDO in WSH上找到有关ASP Free的更多信息。

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

答案 2 :(得分:0)

尝试这个简单的代码。

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

systemProp.http.proxyHost=proxyHost

systemProp.http.proxyPort=proxyPort

systemProp.https.proxyHost=proxyHost

systemProp.https.proxyPort=proxyPort

答案 3 :(得分: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