CreateObject(" Outlook.application"):无法创建ActiveX组件 [英] CreateObject( "Outlook.application") : Cannot create ActiveX component

查看:372
本文介绍了CreateObject(" Outlook.application"):无法创建ActiveX组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从VB.net创建一封电子邮件。

代码如下



I am trying to create an email from VB.net.
The code is as follows

Imports Outlook = Microsoft.Office.Interop.Outlook
Public Class InputForm
Private Sub EmailTeam_Click(sender As Object, e As EventArgs) Handles EmailTeam.Click

        Dim Subject As String
        Dim Recipient As String
        Dim Message As String
        Subject = "My Team"
        Recipient = "myemail@address"
        Message = " Team details"
        SendOutlookMail(Subject, Recipient, Message)
    End Sub
    Public Sub SendOutlookMail(Subject As String, Recipient As _
String, Message As String)

        On Error GoTo errorHandler
        Dim oLapp As Outlook.Application
        Dim oItem As Object
       
        oLapp = CreateObject("Outlook.application")
        oItem = oLapp.CreateItem(0)

        With oItem
            .Subject = Subject
            .To = Recipient
            .body = Message
            .Display()
            '.Send()
        End With

        oLapp = Nothing
        oItem = Nothing


        Exit Sub

errorHandler:
        oLapp = Nothing
        oItem = Nothing
        Exit Sub


    End Sub
End Class 





但是当它到达
oLapp = CreateObject(Outlook.application)

它会跳转到errorHandler:并退出子例程。

为什么CreateObject(Outlook.application)不起作用?

我是初学者所以感谢任何帮助。



Dave







But when it gets to
oLapp = CreateObject("Outlook.application")
it jumps to the errorHandler: and exits the sub routine.
Why does CreateObject("Outlook.application") not work?
I am a beginner so any help is gratefully received.

Dave


[edit: updated question title /manchanx]

推荐答案

我现在解决了问题。

我最初使用的是Office 2007.

我装了Office 365.当我对365满意时,我卸载了Office 2007.这似乎损坏了Office 365。 br />
我现在运行维修,一切正常。感谢您的支持。
I have now solved the problem.
I originally had Office 2007.
I loaded Office 365. When I was happy with 365 I unloaded Office 2007. This it seems damaged Office 365.
I have now run a repair and all is OK. Thanks for all your support.


这篇关于CreateObject(" Outlook.application"):无法创建ActiveX组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆