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!

Automatic email function 1

Status
Not open for further replies.

Jahappz

Technical User
Jun 3, 2002
133
SE
Im after a function that emails the admin everytime a new post is created (when the user clicks the button)
without having outlook msg starting and the user have to click "send".

is there a way to make this automatic, so the user doesnt see the email at all?


/Andreas
 
Try something along the lines of the following. Note you can
set constDisplayEmailFirst to True to display the email
first (ie not automatically send it).

Regards...

---

Const constDisplayEmailFirst = False
Const constolMailItem = 0

Sub DoEmail()

Dim objOutlook As Object
Dim objNameSpace As Object
Dim mItem
Dim vEmailRecipient As String
Dim vEmailSubject As String
Dim vEmailBody As String

'Setup standard email objects
Set objOutlook = CreateObject("Outlook.application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")

'Setup email object
Set mItem = objOutlook.CreateItem(constolMailItem)

'Configure individual email items to what you want
mItem.To = vEmailRecipient
mItem.Subject = vEmailSubject
mItem.Body = vEmailBody

'Display with option of sending or send immediately with no preview
If constDisplayEmailFirst Then
mItem.Display
Else
mItem.Save
mItem.Send
End If

Set objNameSpace = Nothing
Set objOutlook = Nothing
etc.
etc.

End Sub

---

 
Sorry, I clipped this from a much bigger procedure I
use. A quick test tells me that you don't need the
objNameSpace lines in the above.

Regards...
 
Private Sub YourButton_Click()
DoCmd.SendObject , , , "person@company.com", , , "Subject", "Body", False
End Sub

This may however display a 'sending' box for a fraction of a second.
You can build "Subject" and "Body" from the database.

And if you attach the code to the AfterInsert event of the form, you don't even need to click the button.

Good luck



[pipe]
Daniel Vlas
Systems Consultant

 
I designed a Work Order system for our employees to use to request help from the MIS department. After they complete the work order and click on the Submit button an automatic email notification is sent to the MIS department (using DoCmd.SendObject). The form is saved and closed and the user is returned to the Main Menu.

I discovered today (after we've used this application for over a year) that if a user decides to immediately send another work order, we receive email notification only on the first work order but not on the second.

Any help for me?

Ann
 
Daniel, thanks for the feedback. Looks like I've got my work cut out for me now 'cause we've got about 50 folks using the system and no software to push updates to them. Guess I'll be visiting everyone personally.

Ann
 
i'm interested in folding in an automatic email capability into my a2k app'n which runs on windows 2000 professional desktops equipped with 'groupwise' (not 'outlook'). the first solution of chickey's looks like it might work, but being the code doesn't mean all that much to me, it'd be great if someone'd pick up this thread again and 'splain it to me.

“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
I would not even use an email program. Instead use NET SEND. Just insert this code and your message will popup when ever you get a post.
I assume this is within a LAN.


Shell("net send yourcomputername place message here")

It's so much easier.

or
shell("net send ipaddress place message here")
 
what i tried to explalin, perhaps imperfectly, is that i want to enhance a form by adding a command button which would have the net effect of emailing a group of usernames a message. the a2k application file (mdb) is on a shared network drive ("I") which all users to whom it would be sent have access (although i don't think that that's a worry).

“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top