Opening outlook 2010 through vbscript

时光毁灭记忆、已成空白 提交于 2019-12-25 01:44:11

问题


I want to send email using outlook 2010, windows 7 & IE8 , what is code required to get the "Outlook.Application" object?.

I tried with CreateObject("Outlook.Application") but getting error "Object Required"


回答1:


Sample Code :-

' 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



回答2:


You can send an email using CDO which is the subsystem that Outlook uses. You can find more information in my article Sending Emails Using CDO in WSH on 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



回答3:


Try This simple code.

This will help you till opening the Outlook and navigate you to Inbox

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


来源:https://stackoverflow.com/questions/9391849/opening-outlook-2010-through-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!