Exchanging data between class modules

Hi,

I have VB6 code to send out email. I have tested it out and is working fine.
I want to re-write this code using class modules to make a dll with some
properties and a method.

I have a murky understanding of exchanging data between class modules and I
need some help.

I proceeded by creating 2 class modules for my project - EmailProp.cls will
have all the definitions for properties and methods. AutoEmail.cls will contain
just the code that that will receive the values from class1 for execution and
sending out the email.

And here is my problem,

When I test the following code 'AS IS', the email gets sent out, but none of
the properties seem to hold their values. i.e., the message, subject, etc. are
all blank. I know I have messed up the variable declarations and in referencing
them.

Any help would be appreciated. I am posted my code below for the 2 class modules.

Thank you in advance - Inayat

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''EmailProp.cls'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private m_sSubject As String
Private m_sAttachment As String
Private m_sBodytext As String
Private m_sRecipient1 As String
Private m_oAutoEmail As AutoEmail

Public Property Get Subject() As String
    Subject = m_sSubject
End Property
Public Property Let Subject(ByVal vData As String)
    m_sSubject = vData
End Property
Public Property Get Attachment() As String
    Attachment = m_sAttachment
End Property
Public Property Let Attachment(ByVal vData As String)
    m_sAttachment = vData
End Property
Public Property Get Bodytext() As String
    Bodytext = m_sBodytext
End Property
Public Property Let Bodytext(ByVal vData As String)
    m_sBodytext = vData
End Property
Public Property Get Recipient1() As String
    Recipient1 = m_sRecipient1
End Property
Public Property Let Recipient1(ByVal vData As String)
    m_sRecipient1 = vData
End Property

Public Sub SendLotusEmail()
    Set m_oAutoEmail = New AutoEmail
    m_oAutoEmail.Send2
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''AutoEmail.cls,''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

Private m_oEmailProp As EmailProp

Private Property Get EmailProp() As EmailProp
    Set EmailProp = m_oEmailProp
End Property
Private Property Set EmailProp(vData As EmailProp)
    Set m_oEmailProp = vData
End Property


Public Sub Send2()

' ParmArrary RecipientList() As Variant)

On Error GoTo Err_Send2

Dim Saveit As Boolean
Saveit = True

Set m_oEmailProp = New EmailProp
   

'Set up the objects required for Automation into notes

Dim Maildb      As Object      'The mail database
Dim MailDoc     As Object      'The mail document itself
Dim AttachME    As Object      'The attachment richtextfile object
Dim EmbedObj    As Object      'The embedded object (Attachment)

Dim UserName As String         'The current users notes name
Dim MailDbName As String       'THe current users notes mail database name

'Dim arrRecipientList(2) As Variant
'arrRecipientList(0) = m_oEmailProp.Recipient1
'arrRecipientList(1) = Recipient2
'arrRecipientList(2) = Recipient3

Dim Session As Object 'The notes session
'Start a session to notes
Set Session = CreateObject("Lotus.NotesSession")

Call Session.Initialize("password")        

'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string

UserName = Session.UserName

MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"

    Dim dir As Object

    Set dir = Session.GETDBDIRECTORY("")
    Set Maildb = dir.OpenMailDatabase()

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT


    MailDoc.REPLACEITEMVALUE "Form", "memo"
    MailDoc.REPLACEITEMVALUE "Subject", m_oEmailProp.Subject
    MailDoc.REPLACEITEMVALUE "Body", m_oEmailProp.Bodytext

    MailDoc.REPLACEITEMVALUE "SendTo", m_oEmailProp.Recipient1
   
    MailDoc.SAVEMESSAGEONSEND = Saveit

    'Set up the embedded object and attachment and attach it
    If m_oEmailProp.Attachment <> "" Then
        Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
        Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", m_oEmailProp.Attachment, "Attachment")
        MailDoc.REPLACEITEMVALUE "CreateRichTextItem", ("Attachment")
    End If
   
    'Send the document
    MailDoc.REPLACEITEMVALUE "PostedDate", Now() 'Gets the mail to appear in the sent items folder
    MailDoc.Send False, "LName"
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing

Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing

Set m_oEmailProp = Nothing

'MsgBox "Message sent successfully..."

Exit_Send2:
    Exit Sub
Err_Send2:
    MsgBox Err.Description
    Resume Exit_Send2
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Inayat081501Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wraith821Commented:
this instanciates your properties class:
 Set m_oEmailProp = New EmailProp

when the sub Send2 completes the m_oEmailProp is destroyed. clearing all the properties.

make it all one class.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Inayat081501Author Commented:
wraith821:

Thank you for your suggestion. Yes, I got it working. I put it all in a single class. You get the points.

Is having two separate classes, one for just the public properties and methods, not possible, or not a good idea?

Please let me know. Thanks - Inayat
wraith821Commented:
Best prectice in my opinion. keep all properties and methods for the class that it pertains too together. so when you instanciate one object you get everything and everything is destroyed when you kill just one object.
Inayat081501Author Commented:
wraith821:

Makes good sense. Thank you. - Inayat
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.