473,511 Members | 15,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: Newbee question, regarding a couple of syntaxes in c#

Hi!

I was testing an application that is writing a mail and sends it to a
recieptiens. I then came across
a couple of ??? in my head, coul anyone briefly tell me what the difference
is between this and where in the help i can read more about it

First out...

Outlook.Application oApp = new Outlook.Application();
My guess is that this create a new object oApp from this
Outlook.Application? Right?

Then the following, i just don't get, what they do and what it is called...

Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
(Why not xxx = new xxx)

Outlook.MailItem oMsg =
(Outlook.MailItem)oApp.CreateItem(Outlook.OlItemTy pe.olMailItem);

Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;

Thanx in advance for any help

Regards

Martin Arvidsson
Nov 16 '05 #1
2 1540
Hi,
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
(Why not xxx = new xxx)

Outlook.MailItem oMsg =
(Outlook.MailItem)oApp.CreateItem(Outlook.OlItemTy pe.olMailItem);

Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
You don't need to create new namespace (therefore there is no xxx = new xxx
:)), but you get the namespace from the outlook application object you
created. Same goes with MailItem -> you call method CreateItem with
parameter which descibes the item you are creating (olMailItem) and because
CreateItem returns object you have to cast that to Outlook.MailItem.

Hope this helps..

--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
"Visual Systems AB (Martin Arvidsson)" <ma**************@vsab.net> je
napisal v sporoèilo news:%2****************@TK2MSFTNGP15.phx.gbl ... Hi!

I was testing an application that is writing a mail and sends it to a
recieptiens. I then came across
a couple of ??? in my head, coul anyone briefly tell me what the
difference
is between this and where in the help i can read more about it

First out...

Outlook.Application oApp = new Outlook.Application();
My guess is that this create a new object oApp from this
Outlook.Application? Right?

Then the following, i just don't get, what they do and what it is
called...

Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
(Why not xxx = new xxx)

Outlook.MailItem oMsg =
(Outlook.MailItem)oApp.CreateItem(Outlook.OlItemTy pe.olMailItem);

Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;

Thanx in advance for any help

Regards

Martin Arvidsson

Nov 16 '05 #2
> Outlook.Application oApp = new Outlook.Application();
My guess is that this create a new object oApp from this
Outlook.Application? Right?
Yes!
Then the following, i just don't get, what they do and what it is
called...

Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
(Why not xxx = new xxx)
GetNamespace is a factory method. A factory is a method that creates an
object instance for you based on parameters or other stimuli.
On the inside the GetNamespace method could do something like this:
public NameSpace GetNamespace(string ns) {
if (ns=="mapi") return new MapiNamespace();
else return new OtherNamespace();
}

Outlook.MailItem oMsg =
(Outlook.MailItem)oApp.CreateItem(Outlook.OlItemTy pe.olMailItem);
The CreateItem is another factory method. This method creates the item type
you ask for, in your example an olMailItem. Because the return type of the
factory is a base class you have to cast it to the more specific type
MailItem.
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;

Same as above. The Recipients property is casted to a Recipients type.

Anders Norås
blog: http://dotnetjunkies.com/weblog/anoras
Nov 16 '05 #3

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

Similar topics

5
1633
by: Adam | last post by:
Hi, Me very confused. I have some XML that I want to convert to a more basic XML. I have put an example of what I have and what I want, I have used XSL to convert XML to HTML, but never this way. ...
2
1630
by: Newbee Adam | last post by:
some said that .NET app can run on any program where rutime exists. What is "runtime" in this sense? will I have to install runtime or .net framework or .NET support on an xp machine for a...
16
2067
by: WindAndWaves | last post by:
Hi there I have $initstartdate = date("d-m-Y"); in my code How can I get it to be date() + 1 or 7 for that matter. Because my server is in the US and I am in New Zealand, they are always...
4
1772
by: PerryC | last post by:
All, 1. Do the following codes seem ok? 2. If so, then how do I pull the value of YOE1 and YOE2 into my report? (to do some further calculations) ...
9
341
by: EMW | last post by:
I have created a page in aspx and after a click on a button, a new page should open. How is this possible? I tried it doing it like in vb.NET with opening a new form, but it doesn't work. rg,...
1
1753
by: Juan R. | last post by:
Introduction I am developing the CanonML language (version 1.0) as a way to generate, store, and publish canonical science documents on the Internet. This language will be the basis for the next...
2
1400
by: Mel | last post by:
I have a selection box with 3 values. what i need is to pass 3 urls to a function that has a switch statement and based on the selection index goes on one of the tree urls. Question is how do i...
0
1301
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I have a couple of newbee questions. I have a .aspx page with a couple of TextBoxes and a submit button. Now... When i press the submitbutton i want the data in the TextBoxes to be...
0
7153
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
7371
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
7432
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
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5676
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,...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.