473,324 Members | 2,246 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,324 software developers and data experts.

Inheritance - System.Net.Mail namespace

We are having to extend the System.Net.Mail namespace and need some help
with coding it.

We have added several properties to System.Net.Mail.Attachment and need to
add our several of them to System.Net.Mail.MailMessage.Attachments.

// public AttachmentCollection Attachments { get; }

How do we override AttachmentCollection to be a collection of
OurNamespace.Attachments?

How then do we override MailMessage to be the above collection?

public class MailMessage : System.Net.Mail.MailMessage

{

public MailMessage()

{

}
private int _shipmentID;

public int ShipmentID

{

get { return _shipmentID; }

set { _shipmentID = value; }

}

private int _shipmentEmailsID;

public int ShipmentEmailsID

{

get { return _shipmentEmailsID; }

set { _shipmentEmailsID = value; }

}

// overide attachments

public override ?

}

public class Attachment : System.Net.Mail.Attachment

{private int _documentsID;

public int DocumentsID

{

get { return _documentsID; }

set { _documentsID = value; }

}

}
Aug 1 '08 #1
2 2366
On Aug 1, 3:34*pm, "Prefers Golfing" <prefersgolf...@gmail.comwrote:
We are having to extend the System.Net.Mail namespace and need some help
with coding it.

We have added several properties to System.Net.Mail.Attachment and need to
add our several of them to System.Net.Mail.MailMessage.Attachments.

// public AttachmentCollection Attachments { get; }

How do we override AttachmentCollection to be a collection of
OurNamespace.Attachments?
you can't Attachments is not a virtual member in MailMessage.
What this means is that if you pass an instance of your new class to a
method that use a MailMessage it will use MailMessage's member, not
yours.

If you will use your class only with your new classes then you are ok,
just define Attachments in the same way.

Aug 1 '08 #2
Prefers Golfing wrote:
We are having to extend the System.Net.Mail namespace and need some help
with coding it.

We have added several properties to System.Net.Mail.Attachment and need to
add our several of them to System.Net.Mail.MailMessage.Attachments.

// public AttachmentCollection Attachments { get; }

How do we override AttachmentCollection to be a collection of
OurNamespace.Attachments?

How then do we override MailMessage to be the above collection?
I think we have a classic case of trying to extend classes that
were not intended to be extended.

Or to put it another way: I think you need to either live with
the standard .NET functionality or implement your own mail
framework from scratch (the protocols are reasonable simple
to implement).

Arne
Aug 1 '08 #3

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

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
4
by: Roy Pereira | last post by:
I have an application that is composed of a set of "Content" dlls and a viewer application. The viewer calls a standard set of functions that are present in all the dlls. I maintain this by...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
1
by: Michael | last post by:
Hello, I'm trying to implement sample I found on page templates, so I do not have to maintain "<html><head>..." on all my documents. But don't let that confuse you, this is an inheritance...
3
by: Chris Kennedy | last post by:
What's the difference between importing a namespaces and inheriting.
7
by: Sergey Poberezovskiy | last post by:
Hi, I created two base forms: frmList and frmDetail, compiled them into a dll, and then want to use in my new project. The problem: When I created new inherited form, say frmClients, I cannot...
0
by: Ron P. Cuirle | last post by:
I'm trying to extend System.Web.Mail.MailMessage in my own class. Let's call it Company.Common.MailMessage. My project obviously has a reference to System.Web.dll - in order to inherit from...
1
by: Ranginald | last post by:
I am learning OOP and C# and am using VWDExpress to create some practice examples to understand inheritance. Could someone explain why the following is happening: I get the error: 'The type or...
49
by: Ben Voigt [C++ MVP] | last post by:
I'm trying to construct a compelling example of the need for a language feature, with full support for generics, to introduce all static members and nested classes of another type into the current...
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: 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...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.