'Mail to all' button (1 Viewer)

fluidmind

Registered User.
Local time
Today, 07:58
Joined
Jun 30, 2006
Messages
66
Hi there!

I've searched this forum for like 30 minutes now, but I can't find exactly what I'm looking for. So I really hoped you guys could give me an answer instead. I'm quite new to this Access-programming stuff, so I would really prefer if you would relate to this question instead of posting hyperlinks to other posts. :)

Here's the deal: I have a table "employeedata" with a column "email". When I press a button in my form, I would like an Outlook-window to open, with the emails from my table written in the "to:" field.

Should be really simple, I know. But I really can't seem to figure it out!

Thanks in advance!

JR
 

Robert88

Robbie
Local time
Today, 15:58
Joined
Dec 18, 2004
Messages
335
Hi fluidmind,

Can't you just ensure the email addresses are hyperlinks and it should bring up the window you are after?

Robert88
 

fluidmind

Registered User.
Local time
Today, 07:58
Joined
Jun 30, 2006
Messages
66
Thank you very much for your quick response. Well I'm not looking for a button that sends out emails to one employee at a time. I need a button that sends an email to all employees...

The to:-field in Outlook should look somewhat like this:

to: employee1@email.com; employee2@email.com; employeeN@email.com

They are in fact allready saved in the table as email-adresses...
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Yesterday, 22:58
Joined
Nov 8, 2005
Messages
3,294
check the samples d/bases - its their somewhere
 

Robert88

Robbie
Local time
Today, 15:58
Joined
Dec 18, 2004
Messages
335
Hi fluidmind,

Attached is an email.zip that might help you?

Another thought if you have any control over your Exchange Server (Microsoft Mial Server), create an additional email group account and include all users within, so say employee_all@email.com, which sends it too employee1@email.com; employee2@email.com; employeeN@email.com.

But I will understand if you do not want to sent it too all so that you can within Access manipulate and to some degree manage where it is being sent?

HTH, good luck

Robert88
 

Attachments

  • Email.zip
    37.8 KB · Views: 129

fluidmind

Registered User.
Local time
Today, 07:58
Joined
Jun 30, 2006
Messages
66
Hi again!

Thanks to you both!

1) I've tried surfing through the sample-db's, but either it was a lot more advanced than what I needed (or understood) or it was an email-system where you were only able to send it to one single person.

2) The example you attached helped me a lot in understanding the basic concepts of the email-function, but it also was an example of a send-to-one-person system...

So I'm not quite there yet. I'm imagining somewhat like:
Code:
DoCmd.SendObject , , acFormatTXT, "SELECT email FROM employeedata", , , stSubject, stText, -1

I've tried it though, and something seems to be wrong... Could anyone perhaps rewrite the code-sample for me. That would simply be great!!!

// JR
 

fluidmind

Registered User.
Local time
Today, 07:58
Joined
Jun 30, 2006
Messages
66
please help...

Could anyone please help me with this. I'm totally stuck, and it's really important that I'm getting it done...

Thank you in advance...

JR
 

steve-oc

Registered User.
Local time
Today, 06:58
Joined
Aug 25, 2004
Messages
20
Concatenate Emails to Single Field

Code:
Public Function ConcatenateEmails() As String

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim stTo As String
Dim stSQL As String

stSQL = "SELECT email FROM employeedata;"
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset(stSQL)

With rst
    Do While Not .EOF
        stTo = .Fields("Email") & "; " & stTo
    Loop
End With


ConcatenateEmails = stTo

rst.Close
Set rst = Nothing
Set dbs = Nothing

End Function

This is very basic (and untested) but it selects all the emails via the SQL statement and steps through the resultant recordset concatenating them into stTo - seperated by "; ".

You should read up on error trapping and checking the recordset contains data. Also you could add a tick field in your table and add a condition to stSQL - " WHERE MyTickField = True;"

Then use the valure returned by ConcatenateEmails in the To field of your SendObject method.

You'll need DAO referenced.

HTH
Steve
 

fluidmind

Registered User.
Local time
Today, 07:58
Joined
Jun 30, 2006
Messages
66
Thank you very much for your help. It is really, really appreciated...

I will try that right away!
 

dsigner

Registered User.
Local time
Today, 06:58
Joined
Jun 9, 2006
Messages
68
Just had a look at this thread. Aren't you trying to solve the problem in the wrong place? Surely if you group all the employees in the Outlook address book then you only have to address the e-mail to a single item - the group.
 

steve-oc

Registered User.
Local time
Today, 06:58
Joined
Aug 25, 2004
Messages
20
Agreed - that is the neatest solution (provided you can manage your Outlook lists) but was just trying to illustrate the principle of solving the original question ie get a list of email addresses in the To: field.

Should also point out my code will loop forever with out a .MoveNext here:

Code:
With rst
    Do While Not .EOF
        stTo = .Fields("Email") & "; " & stTo
	
	.MoveNext

    Loop
End With

Sorry about that...
 

Users who are viewing this thread

Top Bottom