473,587 Members | 2,547 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.Applica tion oApp = new Outlook.Applica tion();
My guess is that this create a new object oApp from this
Outlook.Applica tion? Right?

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

Outlook.NameSpa ce oNS = oApp.GetNamespa ce("mapi");
(Why not xxx = new xxx)

Outlook.MailIte m oMsg =
(Outlook.MailIt em)oApp.CreateI tem(Outlook.OlI temType.olMailI tem);

Outlook.Recipie nts oRecips = (Outlook.Recipi ents)oMsg.Recip ients;

Thanx in advance for any help

Regards

Martin Arvidsson
Nov 16 '05 #1
2 1547
Hi,
Outlook.NameSpa ce oNS = oApp.GetNamespa ce("mapi");
(Why not xxx = new xxx)

Outlook.MailIte m oMsg =
(Outlook.MailIt em)oApp.CreateI tem(Outlook.OlI temType.olMailI tem);

Outlook.Recipie nts oRecips = (Outlook.Recipi ents)oMsg.Recip ients;
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.MailIte m.

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******** ********@TK2MSF TNGP15.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.Applica tion oApp = new Outlook.Applica tion();
My guess is that this create a new object oApp from this
Outlook.Applica tion? Right?

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

Outlook.NameSpa ce oNS = oApp.GetNamespa ce("mapi");
(Why not xxx = new xxx)

Outlook.MailIte m oMsg =
(Outlook.MailIt em)oApp.CreateI tem(Outlook.OlI temType.olMailI tem);

Outlook.Recipie nts oRecips = (Outlook.Recipi ents)oMsg.Recip ients;

Thanx in advance for any help

Regards

Martin Arvidsson

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

Outlook.NameSpa ce oNS = oApp.GetNamespa ce("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(st ring ns) {
if (ns=="mapi") return new MapiNamespace() ;
else return new OtherNamespace( );
}

Outlook.MailIte m oMsg =
(Outlook.MailIt em)oApp.CreateI tem(Outlook.OlI temType.olMailI tem);
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.Recipie nts oRecips = (Outlook.Recipi ents)oMsg.Recip ients;

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
1641
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. The <item numberingtext="10.01.01 "> I want in the para tag I think, but if it has to be it own tag, no worrys. Any help would be fantastic ...
2
1642
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 .NET app to work? keep in mind I am a newbee :-) !! thanks --
16
2085
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 a day behind....
4
1774
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) ************************************************* Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer) Dim YOE1 As Double
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, Eric
1
1760
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 version 2.0 of the website of the Center for CANONICAL |SCIENCE). The current preliminary version -in proof stage- has been developed on XHTML 1.1 +...
2
1411
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 pass these three urls to the function i already have ? The list size may change and does not necessary have to remain as 3 thanks for lifting a...
0
1304
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 saved in my Sql Table.
0
7920
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.