OutAs the title suggests, I'm using an infopath form to submit an outlook meeting request to receipients using outlook 2003 or 2007. I'm using visual studio 2005 (which incorporates visual basic 2005) for coding. I've found many code samples online, but am having trouble getting the code to work correctly and need some advice.
The following code:
Imports Microsoft.Office.InfoPath
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports System.Xml
Imports System.Xml.XPath
Imports mshtml
Imports Microsoft.Office.Interop.Outlook
Sub CTRL34_7_OnClick(eventObj)
Dim objOutlook
Dim itmAppt
Set objOutlook = CreateObject("Outlook.Application")
Set itmAppt = objOutlook.CreateItem(1)
itmAppt.Subject = "Test"
itmAppt.Start = "15/09/12"
itmAppt.Duration = 60
itmAppt.AllDayEvent = True
itmAppt.ReminderSet = True
itmAppt.ReminderMinutesBeforeStart = 5
itmAppt.Save
End Sub
Provides me with this error:
System.Security.SecurityException
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b88a5c571944e016' failed.
at Microsoft.VisualBasic.Interaction.CreateObject(String ProgId, String ServerName)
at temporary_program_test.FormCode.CTRL1_5_Clicked(Object sender, ClickedEventArgs e)
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
One of the suggested fixes for this is to enable full trust settings in the .Net configuration. After doing this, I still receive the error.
I have also tried other code samples from the following websites, but this time I receive object not defined errors. My attempt to remedy this error was to add resources or "Imports" commands, which also yielded no results. (e.g. Microsoft Outlook 12.0 Object Library).
http://www.visualbasic.happycodings.com/Internet_Web_Mail_Stuff/code4.html
http://www.outlookcode.com/codedetail.aspx?id=88
http://support.microsoft.com/kb/313789
Any help would be greatly appreciated!