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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mailing Forms

Status
Not open for further replies.

generaluser

Technical User
May 24, 2002
79
0
0
US
I want to create a command button that allows you to email the current record to an individual. Is it possible? Please let me know.
 
sure...

General Declarations
Dim outApp As Outlook.Application
Dim outMessage As Outlook.MailItem

Private Sub cmdSend_Click()
On Error GoTo Err_cmdSend_Click

'create outlook instance
Set outApp = CreateObject("Outlook.application")
Set outMessage = outApp.CreateItem(olMailItem)

'assign the message variables
With outMessage
.BCC = strBCC
.Subject = "MySubject" & Me.NewsLetterDate.Value
.Body = Me.FormItem.Value 'or create strBody with all the details from the form that you want to send...
End With

'send the message
outMessage.Send

DoCmd.Close

Exit_cmdSend_Click:
Exit Sub

Err_cmdSend_Click:
MsgBox Err.Description
Resume Exit_cmdSend_Click

End Sub


hth

Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Thanks.

Now, do I type 'Me.NewLetterDate.Value' and 'Me.FormItem.Value' litterally or do I substitute the the name of the form.

Also, on the actuall command button: What event procedure would I put the formula in?

Excuse my ignorance but I'm not all that familiar with VBA. Thanks for the help
 
Sub in the names of the elements on the form

me.mytextbox.value

What does the formula do?
Acutally doesn't matter. I would create a new Sub End Sub routine to handle the calcs. Declare the variable so they have global scope on the form (in the General Declarations section)

Call the sub like this

Call DoCalcs

somewhere in the onClick on the send button BEFORE you actually send it.

For the Body of the email you might want to add the labels so the record makes sense when the user receives the email.

dim strBody as string

strBody = "MyLabel" & me.mytextbox.value

All of the label type info should be in quotes.

hth

Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top