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!

Send e-mail from access databases 65

Status
Not open for further replies.

tpowers

Technical User
Nov 2, 2002
153
0
0
US
Now I am a new guy on the block, so bear with me. I have a form that users are entering client information into all day, and I have been asked to set the database up so that when the are done entering the record that it will automaticlly send the client a confirmation e-mail that the record as been recieved and entered into our database.

Again I am new at this so if so one as a clue of how to do this that would be great.


 
Actually, none of that worked very well. But I fixed the problem by doing like the following:

Dim strEmail As String
Dim strBody As String
.....................


Email.setfocus
strEmail = Email.Text

Body.setfocus
strBody = Body.Text

etc.


Thanks for your help. As you can tell, I'm relitively new to this stuff, and missed a simple answer.
 
Truly sorry to bump up this thread, the information is great. Someone already asked how to set the "From/Sender", and the reply didn't quite do it for me.

I have very basic needs, I'm just using,

Private Sub email_Click()
If Len(Me.email) > 0 Then 'Check to ensure email exists
DoCmd.SendObject acSendNoObject, "test", , Me.email, , , "your subject here", "body text if you want it"
End If
End Sub

The above is all I need. However, I have several email accounts and I'd like to control witch account is used. Just the command to hardcode it to the above would be great. I'm not looking for a routine that will allow selecting the account, just what I need to add to the sub to insure it uses a certain email account.

Also... the above example works, but I have no idea what "test" is for... I just found the code and used it as is.
 
Check out ACCESS Help for the SendObject command. All of the parameters are detailed there for future reference.

As for the "test" in the following:

DoCmd.SendObject acSendNoObject, "test", , Me.email, , , "your subject here", "body text if you want it"

. . .it is the second parameter. Since this command is using the acSendNoObject then the second parameter could be left blank. Because you have something it this parameter it will be ignored. You could leave this one blank in this instance.

If you choose acSendReport then the seond parameter would be the name of the report placed within Quote marks,(i.e. "rptAcctDetails")


Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Thank you for that Bob, and I can assure you I have "RTFM" many times. ;)

Unfortunately ACCESS Help doesn't list a way to set the "From", only the "To". So I'll assume by your answer, (and the fact that it's not mentioned in Help) that there just isn't a way to set the "From", using SendObject.
 
Read all the postings but none applied so here's my question.
I first tried to use this line to e-mail an attachment:

[DoCmd.SendObject acReport, "Report", "SnapshotFormat(*.snp)", "", "", "", "Report", "", False, ""]

It works great with the database window open but if it's closed (at runtime) then it comes up with an error message "Command or Action "OutputTo" isn't available now.
Is there any way I can get around this problem?
qb
 
hey guys ... just wondering if u can sort something out for .. well basically i have set up a database which is running fine .. but theres one thing i need to do, which is, when i delete all records from the tables i want the AutoNumber to restart again .... for some reason i cant seem to get it to work ... can u help ??
 
Dear 159159,

I am not sure that your question belongs in this thread regarding email, but since you asked,

1) Create a Blank default table with the key field at it's initial value. (This is your template)
2) Now, when you want to restart the Auto number field,
use the copyobject method to copy this 'template' table to your live table.

Now, the autonumber field will start over.

Note: This only will work since you stated that you delete all the records.

Hope This Helps,
Hap [2thumbsup]


Access Developer [pc] - [americanflag]
Specializing in Access based Add-on Solutions for the Developer
 
This was wonderful information! One question about emailing through Access - how would the code change for Outlook Express? I have a client who wants to be able to click on the email address in a form and have Express pop up with the To line filled in.

Thanks so much!
Gina
 
Hi Gina,

Outlook Express is not "programable" as is Outlook. You can use docmd.sendobject to send via outlook express (assuming it is the default email client).



Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
Hi everyone - excellent thread. Can I just confirm my suspicions regarding the Outlook model? I have some code that monitors a specific Outlook folder for emails arriving. It works great and allows me to do all sorts of wizz-bang things. However I really do want to extract the sender's email address. Is there a way to do this? Someone p there way above me (in more than one sense) mentioned creating a reply and finding the email address from that. Does that work? and if so how?

Hanging on your every thread
 
This thread has been a tremendous help to me. My thanks to everyone.

I have two questions. In my Access DB, each record has a unique image (adobe acrobat file). Either it can a hyperlink file or embedded as an image. I want to send the Adobe file as an attachment. The example in Nathan1967's post dated 11/12/03 shows the following.

.Attachments.Add ("c:\lott.txt") 'add attachment

I want to be able to attach a file from either the embed field called ImageOfDocument or the hyperlink field called AdobeLink. What is the correct syntax?

Also, I have two subforms. What is the correct syntax to identify these fields. Let's say I have a date in the subform. When I enter the following:
strBody = forms!tblProjectsubform!txtTDate

"Microsoft Access can't find the form tblProjectsuboform referred to in a macro expression or Visual Basic Code." Any help will be appreciated

Sincerely,
Sharon Niles

 
Thank you all so much for this (Esp. Nathan 1967), It has helped me with my database and Access knowledge loads.


[bigsmile] [bigsmile] [bigsmile]
 
Out of interest does anyone know how to send the email when you get the e-mail address form a list box ?
I have groups of e-mail that i need to send in one go, i have created a query that creates a table with the selection i choose and then displays them in a list box on the form, I am then trying to run the e-mail option from the list box but it is either just saying Null Value or displaying the same e-mail address no matter what is in the list box.
Any Ideas would be greatly appreciated.
I have included the code i'm using below.
Thanks

***************************************************

Private Sub Command3_Click()
Dim EMailAddress_1 As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

EMailAddress_1 = Me.List6
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = EMailAddress_1
.Display
End With
Exit Sub
********************************************************
[smile]
 
HI,

This thread has helped me out a great deal. I was't even sure where to start on emailing from Access. I wouldn't have made it this far without it!

My question/problem is: I have two Forms/Tables that are linked. I have my data in one and the email address (an other data) in another. The problem is that when I click on the button to send the email I get an error that it cannot find the other form.

Weird thing is that if I have that form open and point to email address I want to send to and click the email button it will send it out.

The line that has the problem (That Microsoft Visual Basic highlights in yellow) Email = Forms!Library.Library_Email
Here is the code:

Private Sub Email_Requests_Click()
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

'**************************************************************
'*create string with email address
Email = Forms!Library.Library_Email

strBody = txtTDate & Chr(13) & Chr(13)
strBody = strBody & "LB: PINC 209" & Chr(13) & Chr(13)
strBody = strBody & "SL: " & Forms!Requests.SL & Chr(13) & Chr(13)
strBody = strBody & "AU: " & Forms!Requests.AU & Chr(13) & Chr(13)
strBody = strBody & "TI: " & Forms!Requests.TI & Chr(13) & Chr(13) & Chr(13) & Chr(13)


'***creates and sends email
With objEmail


.To = Email
.Subject = "ILL Request"
.Body = strBody
.Send
End With


'Set objEmail = Nothing
'****closes Outlook. remove if you do not want to close Outlook
'objOutlook.Quit

'Exit Sub

End Sub

Any help would be greatly apreciated!

mkacz



 
Dear Mkacz,

Any time you refer to a field on any form, that form (where the field is defined) must be running, otherwise access will be unhappy. Note, you can hide the form, but it still must be running/open.

Why don't you just open a recordset and retrieve the email address from the form that is sending the email?
or
Set a Global shared variable to hold the email address?

Hope this Helps,
Hap [2thumbsup]


Access Developer [pc] - [americanflag]
Specializing in Access based Add-on Solutions for the Developer
 
Hi everyone!

Thanks to all who provided their expertise on this subject. I found it very helpful also! If you will allow me, I have one more question to add to this long thread.

Is it possible to put a follow-up flag on the email? It will be similar to clicking > ACTIONS > FLAG FOR FOLLOW UP when sending the email manually via Outlook.

Thanks!
 
Read this thread with great interest, it's all helped a lot with a small database I'm working on.
I have a question - can I send an email to a filtered set of records? I've managed to email a report based on the filtered set but I can't figure out how to combine that piece of coding (using iFilterType and ac ApplyFilter) with the code supplied by Cricker (way back in January)
I hope I'm not intruding and that someone can assist.
Many thanks


:)I Leco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top