I need to mimic the adress book control in an Outlook VSTO project. It would be much simpler to use the real control, isn't it?
So, do you know a way to expose the address book control, and get what's selected within, of course?
Edit: Never mind, re-creating a basic version of the control will be way easyer.
Solution: third party Redemption library offer this feature.
RedemptionLoader.RDOSession.AddressBook.ShowAddressBook(...)
You don't need to use a third party addin. you can do it with this:
http://msdn.microsoft.com/en-us/library/office/ff868361.aspx
this code below is in VBA but you can easily convert it to C#:
Sub SelectRecipients()
Dim oMsg As MailItem
Set oMsg = Application.CreateItem(olMailItem)
Dim oDialog As SelectNamesDialog
Set oDialog = Application.Session.GetSelectNamesDialog
With oDialog
.InitialAddressList = _
Application.Session.GetGlobalAddressList
.Recipients = oMsg.Recipients
If .Display Then
'Recipients Resolved
oMsg.Subject = "Hello"
oMsg.Send
End If
End With
End Sub
Related
We migrate our vb6 project to use sidebyside(regfree) tehnology ....but have problem with dynamic add control to form like:
Private WithEvents tmpCtl As VBControlExtender
Private Sub UserControl_Initialize()
Set tmpCtl = Controls.Add("Project2.UserControl1", "ctl")
With tmpCtl
Set .Container = Me
.Visible = True
End With
End Sub
and when use tmpCtl object like:
tmpCtl.Properties
we got error "object doesn't support this property or method"
I found that people have like same problem (Strange Case of the missing method: SXS and Controls.Add results in "object doesn't support this property or method"?) and suggestion is implement "Direct user control".
Can somebody know how implement this in vb6 code? How we can fix problem with sxs and dynamic add control to form?
Can give us same example of solution how solve this problem?
I am trying to use the WinSCP COM library on a old VB6 project I have (it's a legacy application that generates an OCX file, I think we have to use VB6 for it but not 100% sure).
Anyway we want to implement SFTP, and WinSCP can do that readily.
I registered the COM object, and can see the WinSCPNet type library when I go to add the reference. However I can't see the properties/methods of the classes when I look at the library in the object browser. Further, this code fails, it does not get to the 3rd MsgBox ("In SendWinSCP4"), it returns from the function at that point, I think because the property UserName is not exposed.
MsgBox ("in SendWinSCP")
Dim session As WinSCPnet.session
Dim sessionOptions As WinSCPnet.sessionOptions
Dim transferOptions As WinSCPnet.transferOptions
Set session = New WinSCPnet.session
Set sessionOptions = New WinSCPnet.sessionOptions
Set transferOptions = New WinSCPnet.transferOptions
MsgBox ("in SendWinSCP3")
sessionOptions.Protocol = Protocol_Sftp
sessionOptions.HostName = "example.com"
sessionOptions.UserName = "user"
sessionOptions.Password = "example.com"
sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
MsgBox ("in SendWinSCP4 " & sessionOptions.HostName & "!")
See above, using On Error Resume Next got me past the error.
I desperately need to access this field in order to develop a Google Contacts sync tool that predominately utilizes the company name as the NAME or FILE AS field, NOT First/Last.
I see it in the XML but no dice via the libraries. I'm using the .NET library.
I figured it out. Here's a little VB.NET code snippet in case anyone else needs to know how to manipulate values not directly exposed by the gData library. This returns the XML node (and creates first it if it doesn't exist). I actually change the value through the innerText property.
Private Function GetFileAsObject() As XmlNode
For Each ext As Object In _contactEntry.ContactEntry.ExtensionElements
If (ext.GetType() Is GetType(XmlExtension)) Then
If ext.XmlName = "fileAs" Then
Return ext.Node
End If
End If
Next
Dim doc As New XmlDocument
doc.LoadXml("<gContact:fileAs xmlns:gContact='http://schemas.google.com/contact/2008'></gContact:fileAs>")
Dim node As XmlNode = doc.DocumentElement
Dim newExt As XmlExtension = New XmlExtension(node)
_contactEntry.ContactEntry.ExtensionElements.Add(newExt)
Return node
End Function
This link helped immensely: http://code.google.com/p/google-gdata/wiki/UnderstandingTheUnknown
I am trying to update an VBA module to use the System.Windows.Forms.FolderBrowserDialog class. I declared my object as follows:
Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog
Running this gave me the error User-defined type not defined. I figured the compiler didn't know about that class so I tried going to Tools > References and adding Systems_Windows_Forms, but I'm still getting the same error. Does anyone know what I'm missing here? Do I need a reference to the library in my code as well?
System.Windows.Forms.FolderBrowserDialog looks like something from .Net to me, not VBA.
You can use Application.FileDialog in Access VBA. This sample uses late binding and allows the user to select a folder from a browse dialog.
Const msoFileDialogFolderPicker As Long = 4
Dim objFileDialog As Object ' FileDialog
Set objFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
With objFileDialog
.AllowMultiSelect = False
If .Show Then
Debug.Print .SelectedItems(1)
End If
End With
If you prefer to use early binding, set a reference to the Microsoft Office [version] Object Library. You could then declare the object like this ...
Dim objFileDialog As FileDialog
And you wouldn't need to define the constant, so discard this line if using early binding ...
Const msoFileDialogFolderPicker As Long = 4
I have a function that re-creates an email using the contents of another email (using the Outlook Redemption library). I have almost finished converting it to early binding (I am using Option Strict ON in vb.net), but visual studio 2010 underlines the .save and .move lines with the error "option strict on disallows late binding."
The code is:
'Use Redemption Library function to re-create email
Dim sItem As Redemption.SafeMailItem
Dim oItem As Object
sItem = New Redemption.SafeMailItem
oItem = myOlApp.Session.GetSharedDefaultFolder(myRecipient, Outlook.OlDefaultFolders.olFolderDrafts).Items.Add(Outlook.OlItemType.olMailItem)
With sItem
.Item = oItem
.Import(tempfilepath, 3) 'olMSG, olRFC822 and olTNEF formats are supported
.Save()
.Move(myolfolder)
End With
Having resolved the other late binding errors I cannot see why the two methods are flagging as a problem.
Help
Lewis
You get that error because SafeMailItem obly implements properties and methods blocked by Outlook.
Since Save and Move are not blocked, SafeMailItem does not implement them, but it is smart enough to pass them through when you are using late binding. Invoke those methods using the original Outlook item:
With sItem
.Item = oItem
.Import(tempfilepath, 3) 'olMSG, olRFC822 and olTNEF formats are supported
oItem.Save()
oItem.Move(myolfolder)
End With