473,396 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problems converting this VB sample code to c#

Hi. I am trying to get Outlook.Items SetColumns method to work, and have
found a relevant knowledge base article Q184462.

I cant cast it to a Outlook.ContactItem (like I would do if I didnt use
the SetColumns) and if I leave it as Object, it contains no FullName and
gives a compile error.

Here is the relevant VB code:

Sub SetColumns_Example()
Dim ol As Outlook.Application
Dim MyFolder As MAPIFolder
Dim itms As Items
Dim itm As Object
Dim dtmStart As Date, dtmEnd As Date
Dim lngElapsed As Long
Set ol = New Outlook.Application
Set MyFolder = ol.Session.GetDefaultFolder(10)
Set itms = MyFolder.Items
itms.SetColumns "[FullName],[CompanyName]"
Debug.Print "WITH SETCOLUMNS"
Debug.Print Time
Debug.Print "------------------"
dtmStart = Time
For Each itm In itms
Debug.Print itm.FullName & ", " & itm.CompanyName
Next

Why doesnt VB give a compile error, class Object does not contain FullName?

Here is my c# code so far:
---
Outlook.Items contactItems = contactsFolder.Items;

contactItems.SetColumns("FullName");

Outlook.ContactItem contact = (Outlook.ContactItem) contactItems.Item
(counter);

string fn = contact.FullName;
----

Without the SetColumns, the cast works. Doing it like the VB snippet,
i.e. contact as an object, I get the compile time error, object does not
contain FullName.

Any hints on how to get this to work in c#?

Thanks a lot.
Nov 20 '05 #1
4 807
Cor
Hi Kurt,

Did you know you are asking the VB.net language group how get something
working in C#? that is written in probably VB6.

But here are some links
VB->C#
<http://www.remotesoft.com/>
C# -> VB .NET Converters:

<http://www.kamalpatel.net/ConvertCSharp2VB.aspx>
<http://csharpconverter.claritycon.com/Default.aspx>
<http://www.ragingsmurf.com/vbcsharpconverter.aspx>
<http://www.aspalliance.com/aldotnet/examples/translate.aspx>
http://www.gotdotnet.com/Community/U...7-979975d5957d
<http://www.remotesoft.com/>
-> "Octopus"

I hope this helps?

Cor

Cor

Nov 20 '05 #2
no, object does not contain much of anything.
I'm not sure why Visual Basic can successfully read
foreach(Object itm in itms)
{
// do stuff
}
Must be some Visual Basic thing that translates Object to Item (or
whatever itms contains)

Ignore the line
Dim itm As Object
and use
foreach(Item itm in itms)
{
// do stuff
}
Substitute "Item" with whatever object type itms contains

OR

cast itms to the proper object before accessing FullName
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 20 '05 #3
Actually he crossposted it because I was reading it in the C# group :P
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 20 '05 #4
Cor
Hi Morten,

I knew that
But thanks for you attention

Cor
Actually he crossposted it because I was reading it in the C# group :P

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kurt Häusler | last post by:
Hi. I am trying to get Outlook.Items SetColumns method to work, and have found a relevant knowledge base article Q184462. I cant cast it to a Outlook.ContactItem (like I would do if I didnt use...
3
by: Stephan Brunner | last post by:
Hi I have created two flavors of an XSLT stylesheet to transform all attributes of an XML document to elements: They both work as expected with MSXML and XMLSPY but throw an exception ...
0
by: John | last post by:
Howdy, everyone... I've read some reference books, checked some old code I wrote and have done some Googling to try and get 'round this but haven't had any joy... The attached code works...
2
by: Matt | last post by:
I just wanted to know if I am converting to/from streams the easiest and correct way. I am performing the following statements to convert byte arrays to and from streams during different...
4
by: Jerry | last post by:
I am new to C# and have been trying to figure out how to access a range passed to C#. I have tried everything I can find and have been unable to get it to work. Here is a test sample Ive been...
3
by: Daylor | last post by:
hi. i got a sample project written in vc6. when i compile and build the exe (debug mode ) , the exe file size is 221KB, and the program work ok. if i open this project in vc7 , build the exe,...
2
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the transparent color turns to blue somewhere in the...
4
by: pmcgover | last post by:
I enjoyed Paul Barry's September article in Linux Journal entitled, "Web Reporting with MySQL, CSS and Perl". It provides a simple, elegant way to use HTML to display database content without any...
21
by: py_genetic | last post by:
Hello, I'm importing large text files of data using csv. I would like to add some more auto sensing abilities. I'm considing sampling the data file and doing some fuzzy logic scoring on the...
2
by: eBob.com | last post by:
I've been working on an app which has an array of RichTextBoxes. And I have a context menu for the RTBs. The context menu has two levels; the first level has two items, "Load Sample Text File"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.