473,379 Members | 1,423 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,379 software developers and data experts.

Q: Using the ref gives me an error...

Hi!

I'm trying to use the "ref" to return a value, see snippet below.
I execute AddTask first, this executes FindTaskByID.

The compiler gives me this error...
(55): Argument '2': cannot convert from
'Microsoft.Office.Interop.Outlook.TaskItem' to 'ref
Microsoft.Office.Interop.Outlook.TaskItem'

The general idea is to check for a task in outlook, if the task doesn't
exist, create a new task
otherwise update the existing...
public bool FindTaskByID(string taskID, ref Outlook.TaskItem task)
{
task = (Outlook.TaskItem)_mapiFolderTask.Session.GetItemF romID(taskID,
_mapiFolderTask.StoreID);
// True if taskID and the searchedID
return (taskID == task.EntryID.ToString());
}

public string AddTask(string subject,
DateTime intDate, DateTime dueDate,
string status, string priority, string entryID)
{
Outlook.TaskItem Task = (Outlook.TaskItem)
_Outlook.CreateItem(Outlook.OlItemType.olTaskItem) ;
FindTaskByID(entryID, Task);

**** CODE END *****

Regards
Martin
Nov 17 '05 #1
1 1361
When you call FindTaskByID, you need to specify that you
are passing the value by reference, to do so you would add
the 'ref' keyword to your call making it look something
like:

FindTaskByID(entryID, ref Task);

Just for note, the same thing needs to be done when using
the 'out' keyword, it must be specified on both the
calling side and on the destination side.
-----Original Message-----
Hi!

I'm trying to use the "ref" to return a value, see snippet below.I execute AddTask first, this executes FindTaskByID.

The compiler gives me this error...
(55): Argument '2': cannot convert from
'Microsoft.Office.Interop.Outlook.TaskItem' to 'ref
Microsoft.Office.Interop.Outlook.TaskItem'

The general idea is to check for a task in outlook, if the task doesn'texist, create a new task
otherwise update the existing...
public bool FindTaskByID(string taskID, ref Outlook.TaskItem task){
task = (Outlook.TaskItem) _mapiFolderTask.Session.GetItemFromID(taskID,_mapiFolderTask.StoreID);
// True if taskID and the searchedID
return (taskID == task.EntryID.ToString());
}

public string AddTask(string subject,
DateTime intDate, DateTime dueDate,
string status, string priority, string entryID)
{
Outlook.TaskItem Task = (Outlook.TaskItem)
_Outlook.CreateItem(Outlook.OlItemType.olTaskItem );
FindTaskByID(entryID, Task);

**** CODE END *****

Regards
Martin
.

Nov 17 '05 #2

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

Similar topics

1
by: sunaina | last post by:
I am doing the following query using intersect but gives me an error 'error in sql syntax. I tried using join as well but gives me similar error. In the following code still has intersect just to...
10
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
2
by: SKB | last post by:
Hi, I am absolutely new to this area. I am getting the following difficulty : Access denied for user 'ODBC'@'localhost' (using password: NO) when I try the mysql command from within the...
3
by: amitsoni.1984 | last post by:
Hi, I have to write a code in python to read a matrix from a text file and for that i am using following code. But it gives an error saying "NameError: name 'split' is not defined". Can anyone...
1
by: OceanBreeze | last post by:
I am using ASP 2.0 and C# I have a TextBox control in .aspx file. <asp:TextBox ID="CityTxt" runat="server"></asp:TextBox> When I click on that text box, I want to trigger onClick event. ...
2
by: danishce | last post by:
I want to load a form dynamically by reading Form Name from a text file using vb.net. In visual basic 6 code works fine but when i use the same code in vb.net it gives the error. The code below...
14
by: jcage | last post by:
Is there any tutorials online for sending email through forms? I can send an email as well as write to my MySQL database from home with the following code but not at work. I think there might be...
2
by: adypoly | last post by:
Hi guys... I am having a typical problem in using one of the native dll in C# I'll explain what am trying to do, I've a dll written in C language which i am trying to include in my C# project,...
65
by: Arjen | last post by:
Hi, Form a performance perspective, is it wise to use the ref statement as much as possible? Thanks! Arjen
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.