Re: Newbee question, regarding a couple of syntaxes in c#
by Peter Jausovec » Sat, 20 Nov 2004 06:37:59 GMT
Hi,
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..
Re: Newbee question, regarding a couple of syntaxes in c#
by Anders Nor » Sat, 20 Nov 2004 06:47:15 GMT
> Outlook.Application oApp = new Outlook.Application();
Yes!
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();
}
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.
Same as above. The Recipients property is casted to a Recipients type.
Anders Nor
blog: http://www.**--****.com/
Similar Threads:
1.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.OlItemType.olMailItem);
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
Thanx in advance for any help
Regards
Martin Arvidsson
2.A couple of questions regarding TextBox
Howdy. I'm a bit new to C# and got a couple of quick questions that perhaps
someone can help me answer. First, is there a property that you set on a
TextBox control that will force the control to accept only numerical data
(i.e. - only numbers 0 to 9, a decimal and the negative sign)? So far, I've
had to do the validation manually on either a key down or OnValidate event.
Secondly, is there any way to preview a key stroke for a given control and
then either accept or toss the value of the key stroke depending on some
sort of pre-defined rule? So for example, if a user were to enter hit the
"a" key while in a text box, what I would like to have happen is to have the
application eat the keystroke and not have the "a" character ever show up in
the text control. Is this possible? Any assistance provided would be
greatly appreciated.
Thanks.
3.Newbee question, regarding database (SQL)
4.Newbee question regarding ADO
5.couple questions regarding marshaling
How are the Marshal.GetManagedThunkForUnmanagedMethodPtr,
Marshal.GetUnmanagedThunkForManagedMethodPtr methods used?
How is the SignatureHelper class used to get a pointer to a method
signature?
I am trying to use a function pointer returned from GetProcAddress.
I know that you can use System.Reflection.Emit to emulate dynamic loading of
dll's. So please do not reply by telling me to use emit.
Thanks,
Ashkan
6. Q: Couple of quiz regarding custom components.
7. Couple of quiz regarding custom components.
8. newbee question about listbox