CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005
    Posts
    20

    Outlook email in VB.NET causes error

    When I run this code on my PC, it works fine - I send the email to myself and it works. But when I deploy it to another PC, it gives me some Microsoft.Office.Interop.Outlook dll error. I'm assuming I need to make a setup project for deployment purposes; but what dll/files do I need to add?

    Here is my code...

    Imports Microsoft.Office.Interop

    Public Class Form1
    Public Sub Send_Email()
    Dim oOutlook As New Outlook.Application
    Dim oMailitem As Outlook.MailItem
    Dim oAttach As Outlook.Attachment

    oMailitem = oOutlook.CreateItem(Outlook.OlItemType.olMailItem)
    oMailitem.To = "johndoe@somewhere.com"
    oMailitem.Subject = "My Subject"

    Try
    oMailitem.Attachments.Add("C:\TEST.TXT")
    Catch ex As Exception
    End Try
    oMailitem.Send()
    End Sub
    End Class

    Any thoughts would be helpful,
    Thanks
    Ben

  2. #2
    Join Date
    Mar 2005
    Posts
    20

    Re: Outlook email in VB.NET causes error

    Nevermind...figured it out. I had to add the Microsoft.Office.Interop.Outlook assembly to the C:\WINDOWS\ASSEMBLY directory...then it worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured