Silverlight application using vb.net. Issue creating new email in lotus notes - vb.net

Im writing a silverlight application in vb.net and need to send an email via lotus notes. I wish to do this by opening the lotus notes client app, open a new email window and substitute all the necessary details (to, subject etc.) in the new email window. I am using the below code but it only OPENS the lotus notes application on the machine, it does not do anything past this. Its seems that everything after the initial CreateObject call is simply ignored, although it doesnt throw any errors. I have attempt to reference interops.domino.dll but being silverlight project visual studio states the dll is not compiled for the silverlight runtime. Any assistance with this would be greatly appreciated.
Dim outlook = AutomationFactory.CreateObject("Notes.NotesSession")
Dim notesdb = outlook.GetDatabase("", "")
notesdb.OpenMail()
Dim doc = notesdb.CreateDocument()
Dim msg = "Hey whats up"
doc.ReplaceItemValue("SendTo", "person#temp.com")
doc.ReplaceItemValue("Subject", "Hello")
Dim rtitem = doc.CreateRichTextItem("Body")
rtitem.AppendText(msg)

All you do in the moment is to create a new document in the backend and fill it with values.
It is like creating a word document without opening it...
You need some more code to actually SHOW the document you created.
In addition you need to assign a Form, otherwise Notes will not know, how to display this document:
Dim session = AutomationFactory.CreateObject("Notes.NotesSession")
Dim notesdb = outlook.GetDatabase("", "")
Dim ws = AutomationFactory.CreateObject("Notes.NotesUIWorkspace")
notesdb.OpenMail()
Dim doc = notesdb.CreateDocument()
Dim msg = "Hey whats up"
doc.ReplaceItemValue("Form", "Memo")
doc.ReplaceItemValue("SendTo", "person#temp.com")
doc.ReplaceItemValue("Subject", "Hello")
Dim rtitem = doc.CreateRichTextItem("Body")
rtitem.AppendText(msg)
ws.EditDocument( True, doc )
As I do not use silverlight I unfortunately could not test the code, but It should point into the right direction.

You can not do UI manipulations via COM in Notes, as the UI-Classes (NotesUIDocument, NotesUIWorkspace, ...) are not supported via COM.
You can only use the backend-classes likes NotesDocument, ...
This still leaves you a lot of possibilites, as you can eiter use NotesRichTextItem or MIMEEntity classes to compose e-mails.

Related

Direct output straight to printer

I am using the ComponentOne Winforms suite, specifically the FlexReport control, to generate output which will be sent directly to one of several printers. This isn't, I believe, an issue with the ComponentOne suite as I was having similar issues with Crystal.
The end result will run as a VB .Net windows service, but I am having real problems getting it to work. The current code is as follows:
Dim factory As New DatabaseProviderFactory()
Dim sysDb As SqlDatabase
Dim dsOrderList As New DataSet
Dim dsOrderDetail As New DataSet
Dim frPicklist55 As New C1.Win.FlexReport.C1FlexReport
Dim p1 As C1.Win.FlexReport.ReportParameter
Dim options As C1PrintOptions = New C1PrintOptions()
options.PrinterSettings = New PrinterSettings()
options.PageSettings = New System.Drawing.Printing.PageSettings()
'options.PrinterSettings.PrinterName = "\\printsvr\printername"
'options.PrinterSettings.PrinterName = "\\\\printsvr\\printername"
options.PrinterSettings.PrinterName = "Printer1"
sysDb = factory.Create("sys")
dsOrderList = sysDb.ExecuteDataSet("sp_apispool_getorders")
For Each r In dsOrderList.Tables(0).Rows
dsOrderDetail = sysDb.ExecuteDataSet("sp_apispool_getorder", r("order_no"))
frPicklist55.Load("D:\API Spooling Docs\Rpt55Picklist.flxr", "Picklist")
frPicklist55.Parameters("OrderNo").Value = r("order_no")
frPicklist55.Render()
frPicklist55.Print(options)
Next
Specifically, the issues are:
If I use a shared printer ('\printsvr\printername' or '\\printsvr\printername'), I get an exception about the printer settings not being valid.
If I use the local printer ('Printer1'), I get an exception -'Operation is not supported'
This should be really simple, but I suspect I am missing something fundamental. No matter what I do I get an exception at the point I call the Print function.
Any ideas?

How to show up a window of an application with VBA ? (Lotus Notes)

I want to display the Lotus Notes Window when the VBA code is writing the mail in Lotus Notes. I want the Lotus Notes window to be display during all of the operations.
I had tried this code:
Sub init_mail()
Dim oSess As Object
Dim ntsServer As String
Dim ntsMailFile As String
Set oSess = CreateObject("Notes.NotesSession")
ntsServer = oSess.GetEnvironmentString("MailServer", True)
ntsMailFile = oSess.GetEnvironmentString("MailFile", True)
Set odb = oSess.GetDatabase(ntsServer, ntsMailFile)
Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Call Workspace.composedocument(, , "Memo")
Set uidoc = Workspace.CURRENTDOCUMENT
uidoc.Document.deliveryreport = "C"
uidoc.Document.Importance = "Haute"
uidoc.Visible = true
I thought that Visible could say that Lotus Note stay open and visible.
I assume "Visible" should not be utilize in this way. I've got this error:
Execution error '438'
object doesn't support this property or method
good luck with your venture, the OLE/COM Engine for Lotus Notes is antedeluvian and it's a royal pain to debug.
From your code I would hypothesise that you have little experience in LotusScript, you're using programming paradigms that will not work in LotusScript.
Generally I would recommend you first writing code that runs well in the Notes Client, and only when it works, then port it to VBA. Here the integrated Help File is your friend, it's one of the last remnants of when IBM did decent documentation for the Domino/Notes platform. You'll have to wrap your head around a couple of weird concepts (in this particular case, the difference between front-end and back-end documents), and deal with a plethora of maddening bugs.
The following will do what you want it to do. Note that the back-end document gets saved before being displayed in the workspace, this is to be able to display the Rich Text Field which is the body of the Mail.
Dim oSess As Object
Set oSess = CreateObject("Notes.NotesSession")
Dim ntsServer As String
ntsServer = oSess.GetEnvironmentString("MailServer", True)
Dim ntsMailFile As String
ntsMailFile = oSess.GetEnvironmentString("MailFile", True)
Dim Maildb As Object
Set Maildb = oSess.GetDatabase(ntsServer, ntsMailFile)
If Not Maildb.IsOpen Then
Maildb.OPENMAIL
End If
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "Joe Example")
Call MailDoc.REPLACEITEMVALUE("Subject", "Subject Text")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
Call Body.ADDNEWLINE(2)
Call MailDoc.Save(True, True)
Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Call Workspace.EditDocument(True, MailDoc)

VB 2013, modify word document property/custom property

I wish to make an add-in to update word document properties. I’m all ready to go with the addin / ribbon / etc. as I have other ribbon functions that are working. I used the MSVS wizard to create the word ribbon project.
I’m stuck on how to; access the active word document, and access the properties/custom properties. I can’t figure out the; declarations, calls, library, etc. I have not been able to make any of the MSDN samples work…. I’m totally missing something.
For example: ‘ActiveDocument.CustomDocumentProperties’ does not work.
Disclaimer - I’m not a coder. I had this all working with vba, I’m trying to port it over to vb. I’m also still reading through the posted help, and trying samples.
Any suggestions would be appreciated. Kind regards,
I got it figured.
Outside the module declare:
Imports moDoc = Microsoft.Office.Interop.Word
Within the sub - This associates the open app with an object:
Dim oActiveApp As moDoc.Application
oActiveApp = GetObject(, "Word.Application")
Now to associate the open app as a document:
Dim mocCustProperties As Microsoft.Office.Core.DocumentProperties
Dim odpProp As Office.DocumentProperty
Now odpProp is an available to read/add properties:
For Each odpProp In mocCustProperties
If odpProp.Name = “something” Then
‘do dtuff
End If
Next
There must be a way to do this by referencing the active document as a document rather than an application, but I was unable to make this work.
Cheers,
Drat - missed a couple lines above - please ignore.
I got it figured.
Outside the module declare:
Imports moDoc = Microsoft.Office.Interop.Word
Within the sub, This associated the open app with the object
Dim oActiveApp As moDoc.Application
oActiveApp = GetObject(, "Word.Application")
oDocCustomProperty = oActiveApp.ActiveDocument.CustomDocumentProperties
Now to associate the open app as a document
Dim mocCustProperties As Microsoft.Office.Core.DocumentProperties
Dim odpProp As Office.DocumentProperty
mocCustProperties = CType(oDocCustomProperty, Office.DocumentProperties)
Now odpProp is an available to read/add propoeties
For Each odpProp In mocCustProperties
If odpProp.Name = “something” Then
‘do dtuff
End If
Next
Learned some more.
I no longer need the:
Imports moDoc = Microsoft.Office.Interop.Word
Using the Office.Core. rather than the Office.Core.Interop
Dim Prop As Microsoft.Office.Core.DocumentProperty
Dim oBuiltInProperties As Microsoft.Office.Core.DocumentProperties
Dim oCustomProperties As Microsoft.Office.Core.DocumentProperties
oBuiltInProperties = DirectCast(Globals.DocSelect.Application.ActiveDocument.BuiltInDocumentProperties, Microsoft.Office.Core.DocumentProperties)
oCustomProperties = DirectCast(Globals.DocSelect.Application.ActiveDocument.CustomDocumentProperties, Microsoft.Office.Core.DocumentProperties)
For Each Prop In oBuiltInProperties
'do stuff
Prop.Name = sx
sy=Prop.Value.ToString
next
'create properties
sx="New Property"
sy="New Property Value"
oCustomProperties.Add(sx, False, Microsoft.Office.Core.MsoDocProperties.msoPropertyTypeString, sy)
All works now.

Execute custom ArcGIS model with Visual Basic

I made a function which should execute a custom ArcGIS model.
I use VB 2010 with ArcGIS 10.2. The button which should execute this function is placed on a dockable window.
Dim model As Geoprocessor = New Geoprocessor()
model.AddToolbox("D:\Chris\Van Hall Larenstein\Ruimtelijke Informatie Technologie\RPS\RPS.tbx")
Dim parameters As ESRI.ArcGIS.esriSystem.IVariantArray = New ESRI.ArcGIS.esriSystem.VarArrayClass()
model.Execute("RPS_TEST", parameters, Nothing)
There are no errors reported in VB 2010, but it doesn't work in ArcGIS. What am I doing wrong?
EDIT:
Dim pToolHelper As IGPToolCommandHelper2 = New GPToolCommandHelper
'Set the tool you want to invoke.
Dim toolboxPath = "C:\Program Files\ArcGIS\Desktop10.2\ArcToolbox\Toolboxes\Analysis Tools.tbx"
pToolHelper.SetToolByName(toolboxPath, "Buffer")
'Create the messages object to pass to the InvokeModal method.
Dim msgs As IGPMessages
msgs = New GPMessages
'Invoke the tool.
pToolHelper.InvokeModal(0, Nothing, True, msgs)
My.ArcMap.Application.CurrentTool = Nothing
Chris Driessen
If you want user define parameters than this is not the way to do it.
Your code immediately executes the model (without the parameters).
See this link on how to open geoprocessing tool dialog.

How to do Mailmerge in Openoffice using Vb.net

Its 5th Question and apart of one I didn't get response from the experts....
Hope this time I will get the helping hand.
I want to do mailmerge in openoffice using Vb.net and I am totally new with openoffice.
I searched on net for some help to understand how to use openoffice with vb.net but all I get is half info.....So can you please help me and give me code for mailmerge in vb.net for openoffice.
Well i have list of workers in DB and there is this facility that if they want to mail to all or some of the workers then they can do it.I have completed this task using Microsoft Office now as a Add in we are providing the facility to perform the same task using Open Office.
What they have to do is just select the List of workers and click on a button and it will automate the mailmerge using the field of those workers data from DB. The Code of mine is as shown below
Public Sub OpenOfficeMail(ByVal StrFilter As String)
Dim oSM ''Root object for accessing OpenOffice from VB
Dim oDesk, oDoc As Object ''First objects from the API
Dim arg(-1) ''Ignore it for the moment !
''Instanciate OOo : this line is mandatory with VB for OOo API
oSM = CreateObject("com.sun.star.ServiceManager")
''Create the first and most important service
oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
''Create a new doc
oDoc = oDesk.loadComponentFromURL("private:factory/swriter", "_blank", 0, arg)
''Close the doc
oDoc.Close(True)
oDoc = Nothing
''Open an existing doc (pay attention to the syntax for first argument)
oDoc = oDesk.loadComponentFromURL("file:///C:\Users\Savan\Documents\1.odt", "_blank", 0, arg)
Dim t_OOo As Type
t_OOo = Type.GetTypeFromProgID("com.sun.star.ServiceManager")
Dim objServiceManager As New Object
objServiceManager = System.Activator.CreateInstance(t_OOo)
Dim oMailMerge As New Object
oMailMerge = t_OOo.InvokeMember("createInstance", Reflection.BindingFlags.InvokeMethod, Nothing, _
objServiceManager, New [Object]() {"com.sun.star.text.MailMerge"}) 'com.sun.star.text.MailMerge"})
oMailMerge.DocumentURL = "file:///C:\Users\Savan\Documents\1.odt"
oMailMerge.DataSourceName = CreateSource(StrFilter)''Function that will return the datasource name which will be a text file's path
oMailMerge.CommandType = 0
oMailMerge.Command = "file:///C:\Mail.txt"
oMailMerge.OutputType = 2
oMailMerge.execute(New [Object]() {})**---->I am getting Error here**
End Sub