Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing issue in Access 2

Status
Not open for further replies.

nim180

IS-IT--Management
Aug 11, 2005
161
AU
Hey everyone,

I have 2 questions about emailing if someone can help me.

1. I have a continuous form with a dropdown box in the header. If the user clicks on, for example "foreman", it brings up all the information of all the foreman, name, address, phone number and email address. The code below creates an email and takes all the email address for each foreman to send a mass email. The problem I'm having is that it only takes the first 9 email addresses, if there are 10 or more foreman then it will not create an email! How can i get it so that it works for more than 9 fields

Code:
 Private Sub Command6_Click()
 On Error Resume Next
 
 Dim strToWhom     As String
 Dim strMsgBody    As String
 Dim strTitle      As String
 
 With Me.Recordset
 .MoveFirst
 While Not .EOF
 strToWhom = strToWhom & ";" & Me!Email
 .MoveNext
 Wend
 strToWhom = Mid(strToWhom, 2)
 End With
 
 strMsgBody = "Sample"
 strTitle = "Test"
 
 DoCmd.SendObject , , , strToWhom, , , strTitle, strMsgBody, True

End Sub

2. I'm not sure if the following is possible but I'll see if anyone has any idea's. Going from my first question, if the user choose's "foreman" again from the dropdown box and it brings up the name, address, phone no and email address for each foreman. Is it possible that when the user clicks a button an individual email is sent to each foreman with the body of the email with each foremans unique details. So "John Smith" will get an email with only his details," Paul Smith" will get an email with only his details etc.

Thanks,
nim
 

1. How is your recordset created?

2. Perhaps this?
Code:
Private Sub Command6_Click()
    On Error Resume Next
    Dim strToWhom     As String
    Dim strMsgBody    As String
    Dim strTitle      As String
    With Me.Recordset
        .MoveFirst
        While Not .EOF
            strToWhom = strToWhom & ";" & Me!Email
            strToWhom = Mid(strToWhom, 2)
            strMsgBody = "Sample"
            strTitle = "Test"
            DoCmd.SendObject , , , strToWhom, , , strTitle, strMsgBody, True
            strToWhom = ""
            .MoveNext
        Wend
    End With
End Sub



Randy
 
Thanks Randy700, that worked but how do i send the email automatically. Now when i use your code it opens a seperate email for each person but i have to press send on each one. Is there a way it will just automatically send each email?

nim
 
DoCmd.SendObject , , , strToWhom, , , strTitle, strMsgBody, [!]False[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hey PHV,

I still get the same problem where a pop box appears and you have to keep pressing allow for each instance of the email. Is there anyway of when the user clicks the email button that it sends each email automatically without having to press "Allow" or "Send for each email?

Thanks,
Nim
 
Do a google search for outlook object model guard

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV, found what I was looking for :)

nim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top