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

automatic mail after clikcking submit button

Status
Not open for further replies.

mravimtnl

MIS
Nov 1, 2009
47
I have acces form with submit button and drop down list of mails. The Mailing lists are stored in another table. The fileds are Companny name , purchase order number , No of workmen, Location. After hitting the submit button i shall be able to automatically send the mail to the mail adress selected in the menu with the following message in body

Your temp cards are issued. the details ar belwo
company name
PO Number
No of workmen.


I don not know VB. I searched in this forum and configured the code. but i am getting errors.kindly help me.
 
Why not posting your code and the error messages ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Dear sir

error is 424
object required
this is the code



Private Sub Command20_Click()


Dim cn As String
Dim po As String
Dim email As String
Dim wor As String
Dim notes As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

'**gathers information from your form. this sets the string variable to your fields
email = prim!email
cn = prim!cn
po = prim!po
wor = prim!wor
notes = prim!notes

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

'***creates and sends email
With objEmail
.To = email
.Subject = ref & " " & wor & " PO " & cn
.Body = notes
.Send 'sends the email in Outlook. Change to DISPLAY if you want to be able to
'modify or see what you have created before sending the email
End With

'**closes outlook
objOutlook.Quit
Set objEmail = Nothing

Exit Sub
'****end code****




End Sub
help would be highly appreciated
 
prim is my form name. Cn Company Name, Po=purchase order, wr stands for work
 
And which line of code is highlighted when the error raises ?
Anyway, why not using the DoCmd.SendObject method ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I am getting
error at email = prim!email saying object required
 
for DoCmd.SendObject iam getting the same error
 
The error occurs because you have named your variables identical to the controls of your form.
Rename them, e.g.
Code:
Dim varcn As String
Dim varpo As String
Dim varmail As String
Dim varwor   As String
Dim varnotes As String

If you run code in your form, this
Code:
email =
is equivalent to
Code:
Me.email =
or
Code:
prim!email =

Hence your error.
:)

Cheers,
MiS

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
shall i write
prim!email=varemail ??

what shoud i write after prim!email =
becoz i am getting again object error code
 
I have changed the code. However i am getting the same error at .to=email "object 424 explain


Private Sub Command20_Click()
Dim varcn As String
Dim varpo As String
Dim varemail As String
Dim varwor As String
Dim varnotes As String


'**gathers information from your form. this sets the string variable to your fields
email = Me.email
cn = Me.cn
po = Me.po
wor = Me.wor



'***creates and sends email
With objEmail
.To = email
.Subject = cn & " " & wor & "PO " & cn
.Body = cn
.Send 'sends the email in Outlook. Change to DISPLAY if you want to be able to
'modify or see what you have created before sending the email
End With

'**closes outlook
objOutlook.Quit
Set objEmail = Nothing

End Sub
 
If you change the variable names, you must of course change that name everywhere:
Code:
[b]var[/b]email = Me.email
[b]var[/b]cn = Me.cn
[b]var[/b]po = Me.po
[b]var[/b]wor = Me.wor

;-)

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Addition:

Everywhere means you also have to adapt like this
Code:
'***creates and sends email
With objEmail
    .To = [b]var[/b]email
    .Subject = [b]var[/b]cn & " " & [b]var[/b]wor & "PO " & [b]var[/b]cn
    .Body = [b]var[/b]cn
    .Send 'sends the email in Outlook.  Change to DISPLAY if you want to be able to
      'modify or see what you have created before sending the email
End With

OK?
:)


[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Aaargh!
Code:
.Body=var[b][i]notes[/i][/b][code]
of course...

[b][navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell[/b]
 
Hello I was able to send mail by this code till now

However I am now getting an erro 2295 9Run time error and Out look security pop up and unable to send the message. the comment is unknown message reciepints.

. Further i want to know how to send mail through novel groupwise as it is my default e mail client.

the code used by me as follows
Option Compare Database


Private Sub Command14_Click()



Dim CN, PO, nowork, location, work, email As String

stCN = Me.CN
stpo = Me.PO
stnowork = Me.nowork
stemail = Me.email
' DoCmd.SendObject acReport, stDocName
DoCmd.SendObject acSendNoObject, cards, , Me.email, , "Approved Cards", "your cards of M/s" & Me.CN & "under" & Me.PO & "for the work of " & Me.nowork & "is issued.This is an auto gnerated mail. please donot respond", -1, False
Exit_Command14_Click:
Exit Sub



End Sub


However I am now getting an erro 2295 9Run time error and Out look security pop up and unable to send the message. the comment is unknown message reciepints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top