Default value

S

shapper

Hello,

I am creating a class where I have various properties.
I was able to set default values for most properties which have common
types.

However, I am 3 properties which I don't know how to create the default
value:

1. Mail.AttachmentCollection
I want to make it empty. But I am not sure I can do this.

Private _AttachmentCollection As Mail.AttachmentCollection
<DefaultValue("")> _
Public Property AttachmentCollection() As Mail.AttachmentCollection
...

2. Mail.MailAddressCollection
I want to create the default collection with only one MailAddress.
The one which is available in my Web.Config file under:
<system.net>
<mailSettings>
<smtp
deliveryMethod = "network"
from = "atelier@jaquelineroxoatelier">
...

Private _ToCollection As Mail.MailAddressCollection
<DefaultValue("")> _
Public Property ToCollection() As Mail.MailAddressCollection
...

3. Mail.MailAddressCollection
I want this email colection to be empty. Similar to one. It is just
a different collection type.

Private _BccCollection As Mail.MailAddressCollection
<DefaultValue("")> _
Public Property BccCollection() As Mail.MailAddressCollection

4. Mail.MailAddress
I want to create this MailAddress with the datain my Web.Config.
Similar to 2. It is just a MailAddress instead of a Collection.

' From
Private _From As Mail.MailAddress
Public Property From() As Mail.MailAddress
...

Could someone help me out with this?

Thanks,
Miguel
 
G

Gaurav Vaish \(www.EdujiniOnline.com\)

1. Mail.AttachmentCollection
I want to make it empty. But I am not sure I can do this.

Mail.AttachmentCollection.Clear()
2. Mail.MailAddressCollection
I want to create the default collection with only one MailAddress.

Ask SmtpSection to give the appropriate details.
Clear the collection and then add one entry.
3. Mail.MailAddressCollection
I want this email colection to be empty. Similar to one. It is just
a different collection type.

Collections are always 'Clear'-able.
4. Mail.MailAddress

Again, talk to SmtpSection


SmtpSection is in namespace System.Net.Configuration in System.dll

An example:

SmtpSection smtpSettings = (SmtpSection)
ConfigurationManager.GetSection("system.net/mailSettings/smtp",
typeof(SmtpSection));

string from = smtpSettings.From;


--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujinionline.com
http://eduzine.edujinionline.com
-----------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top