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!

Including text and description(title) to an email ?

Status
Not open for further replies.

Schaap

Technical User
Jul 6, 2004
54
0
0
NL
In my Access 2000 database I made some fill in forms for the user.
When the user fills in a new form or changes an existing form then he/she needs to save this form. After saving the form the database opens also an email (to send to me/owner database).

The user has to type text and title of the email and send the email by him/herself. That's not what I want !!!
So my questions are:

Is it possible to write the title of the email and the text(=email) in VBA ? So that the user doens't have to type/do nothing ? And how will that be done/possible ?

And is it possible to do this all at the background, so that the user doesn't see/notice anything ? That means that the click on the emailbutton must be automated into the VBA code I suggest ? Is this also possible, and how will that be done then ?

I need some help to get this started !!!
 
you could use sendobject
docmd.SendObject ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile
 
Ok I can add all the textfields of an email but still can't send the email automatically. So that the user doesn't have to click on the send button of the email !!!

Code:
Titeltxt = "New email"
Bodytxt = "User: " & username & Datum & "-" & InvestNR
DoCmd.SendObject
x = OpenEmailProgram("adres@email.nl", Titeltxt, Bodytxt)

Code of the module ShellExecute:
Function OpenEmailProgram(sDest As String, Optional
sSubject As String, Optional sBody As String, Optional
sCC As String, Optional sBCC As String)apiShellExecute 0,
vbNullString, "mailto:" & sDest & "?subject=" & sSubject
& "&body=" & sBody & "CC=" & sCC & "&BCC=" & sBCC, 0&,
0&, 1
Me.Visible = False
'DoCmd.SendObject
End Function

Does someone know how I can automate my email ?
 
I believe with the SendObject method you can't send automatically. With one of the Outlook 2000 updates the send the e-mail without the prompt was disabled.

However with the CreateObject method you can work around. There are many threads in Tek-Tips giving a more detailed explaination. The following will give you an idea.


Set App = CreateObject("Outlook.Application")
Set ITM = App.CreateItem(olMailItem)

With ITM
.Subject = Esubject
.To = SendTo
.Body = Ebody
.Attachments.Add NewFileName
.Attachments.Add IntFile
.Display 'This opens the e-mail for viewing
' .Send 'This sends without opening the e-mail (you will get the prompt)
End With

SendKeys "%{s}", True 'This sends the e-mail (won't work if you are stepping through)
.MoveNext
Loop
End If
End With
 
You can create a macro with the action "sendto"
Fill in the action arguments... form, form name, etc.
On your form create your button
under the button "on click" event procedure

'Declare variable
Dim stDocName As String
stDocName = "MacroName"
'Save Record to table
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'Run email macro
DoCmd.RunMacro stDocName
End sub

This sends email without user knowing.

Hope this helps.
Kenadys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top