Help emailing copy of forms

Charlottew14

Registered User.
Local time
Today, 14:59
Joined
Oct 4, 2012
Messages
32
Hi, I really hope someone can help because I'm totally stuck!

I've created a database which is used by 4 different "teams" of people, who can only see various bits of information relevant to them.

As part of this, there is a "task manager" section, where people can assign tasks which have come up to other members of the team. There is a form to add a task, and then other areas when you can view or amend the tasks.

The problem has come from trying to send an email "alert" to inform a user than a task has been assigned to them. I've tried using the "EMailDatabaseObject" macro on the form, but this sends over ALL the tasks which have been submitted, not just the one on the screen. Is there any way to ONLY send the record that's shown on screen at that time? Or failing that, sending an email which DOESN'T attach another object?

Also, if it is possible, can the email address be automatically selected, depending on who it's being assigned to?

Any help would be very much appreciated, I'm a bit useless with Access, and have NO experience with VBA or coding, so please make it simple :)

Apologies if this should have gone in the macros thread, I wasn't sure.

Thank you so much!!
 
Hello again,

After much searching, I have come across this piece of code:

Dim olApp As Object
Dim objMail As Object

On Error Resume Next 'Keep going if there is an error


Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open


If Err Then 'Outlook is not open
Set olApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook
End If

'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)

With objMail

'Set body format to HTML
.BodyFormat = olFormatHTML
.To = "name@company.com"
.Subject = "Subject"
.HTMLBody = "Text"
.send

End With

MsgBox "Operation completed successfully"

Which, amazingly, works! However, how can i change the email address to being variable, depending on who the task is assigned for, rather than just one fixed address?

Many thanks!!!
 
.To = "name@company.com"
how can i change the email address to being variable, depending on who the task is assigned for, rather than just one fixed address?

The thing you need to change is the .To property of the email you are sending.

What you could try is to use a Method like this..

Code:
Private sub sendEmailWithAddress(String theEmail as string)

'put your code in here

end sub
Then you can change this
Code:
.To = "name@company.com"
to this
Code:
.To = theEmail
 

Users who are viewing this thread

Back
Top Bottom