473,322 Members | 1,526 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,322 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 22 '05 #1
4 1237
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 22 '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 22 '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 22 '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 22 '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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.