Distribution List

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tara99
    New Member
    • Oct 2006
    • 106

    #1

    Distribution List

    I was wondering if can anyone tell me how can I send email to group of people (based on some criteria) using VB or VBA.

    Let say I have a form which brings in some information and the name of people and their email address, and then I have a button called send. What I want is, when I click on the button "send" I want to be able to send email to those selected peoples.

    Please help
    Tara
  • albertw
    Contributor
    • Oct 2006
    • 267

    #2
    Originally posted by tara99
    I was wondering if can anyone tell me how can I send email to group of people (based on some criteria) using VB or VBA.

    Let say I have a form which brings in some information and the name of people and their email address, and then I have a button called send. What I want is, when I click on the button "send" I want to be able to send email to those selected peoples.

    Please help
    Tara
    hi

    ceate a listbox in your Form with recipient addresses from which to chose
    make sure to enable multisect (here lstAddress)
    put MapiSession and MapiMessage in your Form (here mapSession and mapMsg)
    and try this sample

    [CODE]
    With mapSession
    .DownLoadMail = False
    .LogonUI = True
    .SignOn
    .NewSession = True
    mapMsg.SessionI D = .SessionID
    End With

    With mapMsg
    .Compose
    For i = 0 To lstAddress.List Count - 1
    If lstAddress.Sele cted(i) = True Then
    If .RecipAddress = vbNullString Then
    .RecipAddress = lstAddress.List (i)
    Else
    .RecipAddress = .RecipAddress & "; " & lstAddress.List (i)
    End If
    End If
    Next i
    .MsgIndex = -1
    .MsgSubject = "SUBJECT" 'subject
    .AttachmentPath Name = AttFileName 'filename to assign
    .MsgNoteText = MSG 'message
    End If
    .Send True
    End With
    mapSession.Sign Off
    [CODE]

    Comment

    Working...