Howdy,
A little background, using asp.net 2.0, i'm using a wizard object to create
a email interface for a user to email out their clientele, about 200 or so,
depending on the selection. The first step in the wizard is the email
selection, so it lists all the email accounts and distribution lists the
system has for the user, the user can select lists and/or individuals. I
then read through it all and throw it into an arraylist as a mailaddress
object. The next step in the wizard gives options of whether or not its
displays the selected recipients (including the ones in the lists), format
HTML vs Plain text, BCC the sender, etc. So I loop through all of the
selected emails in my arraylist to display which recipients the user is
emailing to. Here lies my issue.
I need the previously loaded arraylist of selected email addresses to still
be available. The only way i know how to do that is either throw it into a
session variable or the viewstate, both of which requires the class to be
serializable, which MailAddress isn't. I looked into Inheriting and trying
that but I got nowhere fast with that:
<Serializable()> Public Class MailAddress1
Inherits MailAddress
Public Sub New(ByVal email As String, ByVal display As String)
MyBase.New(email, display)
End Sub
End Class
I tried overriding the New sub but it wouldn't let me. So I instead moved
the collecting of email addresses to when the user presses Send. And i do a
lighter collection of the email addresses to a string for displaying their
selected recipients.
SO
I would like to only collect the email addresses once and use the same
arraylist multiple times, on multiple postbacks. Is this possible? I thought
about creating a new class to hold the email address, then transfer them
from my class to the mailaddress class when going to send, but that didnt
make much sens to me to do.
Thanks!!!I think you're stuck with
Create your own Class.
I would write one that had the constructor value needs for the MailAddress
class.
MailAddress (String) Initializes a new instance of the MailAddress
class using the specified address.
MailAddress (String, String) Initializes a new instance of the
MailAddress class using the specified address and display name.
MailAddress (String, String, Encoding)
I'd probably pick the second one.
(Serializable _)
public class MyEMailAddressInfo
property EmailAddress as string
property DisplayName as string
public static (shared in vb.net) GetMailAddress ( e as
MyEMailAddressInfo ) as MailAddress
and then create a collection of these
public class MyEmailAddressInfoCollection : List (Of MyEMailAddressInfo )
( use the inherit keyword instead of the c# ":" of course).
And I'd keep a copy of this object in the Session.
That's what I would do, look for other ideas from others.
Even if that class was serializable, you probably want to keep a "lite"
version of the values (aka the custom collection above) for either Session
or ViewState keeping, because of memory issues.
Keeping around alot of MailAddress objects, just because you need a bunch of
joe@.joes.com values seems non-frugal with the resources
Use the
public static (shared in vb.net) GetMailAddress ( e as MyEMailAddressInfo )
to delay getting those MailAddress objects you need when you actually need
them.
"David Lozzi" <dlozzi@.nospam.nospam> wrote in message
news:8D91BDDA-0C11-425B-8DB3-D1278E4B8C3D@.microsoft.com...
> Howdy,
> A little background, using asp.net 2.0, i'm using a wizard object to
create
> a email interface for a user to email out their clientele, about 200 or
so,
> depending on the selection. The first step in the wizard is the email
> selection, so it lists all the email accounts and distribution lists the
> system has for the user, the user can select lists and/or individuals. I
> then read through it all and throw it into an arraylist as a mailaddress
> object. The next step in the wizard gives options of whether or not its
> displays the selected recipients (including the ones in the lists), format
> HTML vs Plain text, BCC the sender, etc. So I loop through all of the
> selected emails in my arraylist to display which recipients the user is
> emailing to. Here lies my issue.
> I need the previously loaded arraylist of selected email addresses to
still
> be available. The only way i know how to do that is either throw it into a
> session variable or the viewstate, both of which requires the class to be
> serializable, which MailAddress isn't. I looked into Inheriting and trying
> that but I got nowhere fast with that:
> <Serializable()> Public Class MailAddress1
> Inherits MailAddress
> Public Sub New(ByVal email As String, ByVal display As String)
> MyBase.New(email, display)
> End Sub
> End Class
> I tried overriding the New sub but it wouldn't let me. So I instead moved
> the collecting of email addresses to when the user presses Send. And i do
a
> lighter collection of the email addresses to a string for displaying their
> selected recipients.
> SO
> I would like to only collect the email addresses once and use the same
> arraylist multiple times, on multiple postbacks. Is this possible? I
thought
> about creating a new class to hold the email address, then transfer them
> from my class to the mailaddress class when going to send, but that didnt
> make much sens to me to do.
> Thanks!!!
>
0 comments:
Post a Comment