Solved

VB.net Send Outlook Invite

Posted on 2014-02-05
4
763 Views
Last Modified: 2014-02-05
Hi,

How to send meeting invite using VB.Net?

Thanks,

Sanjay.
0
Comment
Question by:sanjay-gandhi
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39835288
How about this from Microsoft:
Imports System.Reflection

Module Module1

    Sub Main()
       ' Create an Outlook application.
        Dim oApp As Outlook.Application = New Outlook.Application()

        ' Get Mapi NameSpace and Logon.
        Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
        oNS.Logon("YourValidProfile", Missing.Value, False, True) ' TODO:
        
        ' Create an AppointmentItem.
        Dim oAppt As Outlook._AppointmentItem = oApp.CreateItem(Outlook.OlItemType.olAppointmentItem)
        'oAppt.Display(true)  'Modal	

        ' Change AppointmentItem to a Meeting. 
        oAppt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting

        ' Set some common properties.
        oAppt.Subject = "Created using OOM in VB.NET"
        oAppt.Body = "Hello World"
        oAppt.Location = "Samm E"

        oAppt.Start = Convert.ToDateTime("11/30/2001 9:00:00 AM")
        oAppt.End = Convert.ToDateTime("11/30/2001 1:00:00 PM")

        oAppt.ReminderSet = True
        oAppt.ReminderMinutesBeforeStart = 5
        oAppt.BusyStatus = Outlook.OlBusyStatus.olBusy  '  olBusy
        oAppt.IsOnlineMeeting = False
        oAppt.AllDayEvent = False

        ' Add attendees.
        Dim oRecipts As Outlook.Recipients = oAppt.Recipients

        ' Add required attendee.
        Dim oRecipt As Outlook.Recipient
        oRecipt = oRecipts.Add("UserTest1") ' TODO:
        oRecipt.Type = Outlook.OlMeetingRecipientType.olRequired

        ' Add optional attendee.
        oRecipt = oRecipts.Add("UserTest2") ' TODO:
        oRecipt.Type = Outlook.OlMeetingRecipientType.olOptional

        oRecipts.ResolveAll()

        'oAppt.Display(true)

        ' Send out request.
        oAppt.Send()

        ' Logoff.
        oNS.Logoff()

    End Sub

End Module

Open in new window

http://support.microsoft.com/kb/313789
0
 

Author Comment

by:sanjay-gandhi
ID: 39836337
Does not work. Either Outlook.Application gives error or only Application gives error. I had downloaded similar code from Net, but that too gave similar errors. I have also included the namespaces mentioned on Microsoft link, but sorry, no gains.

Sanjay.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39836503
That is weird, if you followed these steps that were mentioned in the aforementioned Microsoft How-To you should not be running into an error. Just to make sure, is this what you did:
    1. On the Project menu, click Add Reference.
    2. On the COM tab, click Microsoft Outlook XX.X Object Library, and then click Select.
    3. In the Add References dialog box, click OK to accept your selections. If you are prompted to generate wrappers for the libraries that you selected, click Yes.
0
 

Author Closing Comment

by:sanjay-gandhi
ID: 39837850
Yes, I followed these steps. But it did not ask to generate any wrappers.

But on retry, it asked me to add Imports Microsoft.Office.Interop, and one more namespace.

It has finally worked with the above namespace.

Plus how do I ask the attendee to give accept or reject.

Thanks.
Sanjay.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question