English 中文(简体)
微软视频演播室没有工作的参考资料
原标题:References in Microsoft Visual Studio not working

Currently, I am attempting to send an email using VB.NET. Now, I have added a reference with this code: (I have added placeholders)

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:TempHello.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

如何参考所有展望项目的工作(参考文献)。 应用程序,《展望》。 附文《展望》。

提前感谢。

问题回答

在“解决方案探索者”上点击你的项目,选择“Add Reference”和剪辑,直至见微软。 办公室。 展望和选择。 然后添加“Importssoft”。 页: 1

添加“Microsoft Outlook 11.0 Object Library”的内容:

  1. On the Project menu, click Add Reference.
  2. On the COM tab, click Microsoft Outlook 11.0 Object Library, and then click Select.
  3. Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the library that you selected, click Yes.

在法典中,你必须补充:

Imports Outlook = Microsoft.Office.Interop.Outlook

更多信息见:。 采用Microsoft Office Outlook 2003和视觉基本原理的手套

But if you re in .NET, why not use System.Net.Mail?

Imports Microsoft.Office.Interop

 On the Project menu, click Add Reference.
 On the COM tab, Double click ->  Microsoft Outlook xx.0 Object Library

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 = CType(oApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook._MailItem)
        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:TempHello.txt"
          TODO: Replace with attachment name
        Dim sDisplayName As String = "Hello.txt"

        Dim sBodyLen As Integer = 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




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签