Welcome to Dream.In.Code
Become a VB Expert!

Join 149,380 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,492 people online right now. Registration is fast and FREE... Join Now!




Email Form on Close

 
Reply to this topicStart new topic

Email Form on Close, Visual Basic/Access

P4L
13 Feb, 2008 - 08:18 AM
Post #1

Geek 4 Life
Group Icon

Joined: 7 Feb, 2008
Posts: 1,243



Thanked: 6 times
Dream Kudos: 125
My Contributions
Ok, first post for help, I am trying to create a form in Access, with VB, that will add a person to a distribution list. The issue that I have is that I need for the form to automatically be emailed to the next user, until it has been sent to a group of about 7 people, and then returned to me so I know that it is finished. I have changed the event procedure for on Close to email the form, but I need it to go to the next person one at a time as the form is closed, and I am unable to get the SendObject command to work. The code is below.

CODE

DoCmd.SendObject (acSendForm,"Report Distribution",,"JKiracofe@monlife.com",,,,"Please fill in all provided spaces for each employee in your area. Thank you")


I have not had anyone rely, so let me ask this question, as a new programmer, can anyone recommend a better way to create a form to be emailed to various users without them seeing the full document?

This post has been edited by programming4life: 14 Feb, 2008 - 06:49 AM
User is offlineProfile CardPM
+Quote Post

Banned
RE: Email Form On Close
14 Feb, 2008 - 02:36 PM
Post #2

New D.I.C Head
*

Joined: 18 Oct, 2007
Posts: 12


My Contributions
hi:
As an example, the Function below, ABSendObject function, send a copy of a table, hard-coded as "Company," to the destination you set up. You'll need to provide a valid destination address in sRecipient. The name should be unique in your mail system to avoid MAPI needing to resolve the name when the message is sent.

If you do not specify a unique name, the Send Note dialog will be shown and you will have to specify the name to send the message to.

CODE

Function ABSendObject ()
    'send an object, using MAPI, from Access to
    'another system - this routine is hardcoded
    'to send the company table.

    Dim sRecipient As String
    sRecipient = "Steve Wynkoop;"

    'This example specifies the user to send the object to.
    MsgBox "Sending message to: " & sRecipient & "..."
    DoCmd SendObject A_TABLE, "Company", A_FORMATXLS, sRecipient, , , "Copy of the company database.", , False
    
    MsgBox "Message sent."
End Function



Below the parameters expected by the SendObject method. As indicated before, if you omit these, MAPI will attempt to resolve the information, either by asking the user to clarify something, or by not sending the message and providing your calling routine with an error message.

ObjectType
Use the Microsoft Access intrinsic constants of A_TABLE, A_QUERY, A_FORM, A_REPORT or A_MODULE (better use 'A_FORM' instead of 'acSendForm').

ObjectName
This is the name of what you're going to send. This can be a form or query name, etc.

OutputFormat
These file types are represented by the A_FORMATXLS, A_FORMATRTF and A_FORMATTXT intrinsic constants.

To, CC, BCC, Subject and MessageText
All items are strings, providing the addressee's name, the message subject and any associated message text. BCC is not currently supported by the MSMail client.

EditMessage
True or False. This controls the display of the send note dialog box.

If the recipient information provided is not valid, the message will not be sent. Instead, your routine will receive an error message indicating that the recipient was not valid.

tongue.gif
User is offlineProfile CardPM
+Quote Post

P4L
RE: Email Form On Close
18 Feb, 2008 - 06:54 AM
Post #3

Geek 4 Life
Group Icon

Joined: 7 Feb, 2008
Posts: 1,243



Thanked: 6 times
Dream Kudos: 125
My Contributions
Thank you for this code. With a few modifications, it worked like a charm. The only issue is that I think I was not clear on exactly what I am trying to do, and that is to email the form as an object automatically. If this can not be completed in Access, can someone please let me know a better way to accomplish this would be? Even if it is to use a new program to create the form.
Thank you
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:30AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month