Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Email fro FORM

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
khashid - 11 May 2007 13:31 GMT
Hi All, I need assistance with the following code am using to send an email
from my form.

rivate Sub Command21_Click()
Dim SendTo As String, MySubject  As String, MyMessage As String
SendTo = Me.[Email]
MySubject = "New Complain"
MyMessage = Me.Complaint_No & vbCr & Me.Complaint_Type & vbCr & Me.CSR & vbCr
& Me.Customer_Name & vbCr & Me.Card_No & vbCr & Me.Card_Type & vbCr & Me.
CC_Department & vbCr & Me.Complaint

DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject, MyMessage, True

I need few changes if you can help.
1- Send CC copy
2- MySubject, i want to have the Complain No in the subject in this format
Complain No : [Complain_No]
3- In the MyMessage I want to have the headings with the information because
right now its kindof difficult to figure out the information. I want it this
way
Complain No: [Complain_No]
Customer Name: [Customer_name]
etc....
4- I want the email sent directly as soon the user hits send, right now it
stops for editing.
Daniel - 11 May 2007 14:02 GMT
You'll need to learn to start using the help a bit more.  It covers the
parameters for the sendobject method in detail.

based on the help file we can get the base synthax for this method which is

expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc,
Subject, MessageText, EditMessage, TemplateFile)

1. so to add a Cc recipient you need only add a 5th variable to your coding
2. We need only concateneate the info on the form into a single string
3. Simple string manip.
4. is controled by the EditMessage boolean value

i. you should start calling you buttons by real names and not the default
values (this will simplify your life when reviewing your code at a later
date, trust me!!!).

Private Sub Command21_Click()
Dim SendTo As String
Dim SendCc As String
Dim MySubject  As String
Dim MyMessage As String

SendTo = Me.[Email]
SendCc = "CcRecipientEmailAddressGoesHere"
MySubject = "Complain No :" & Me.[Complain_No]
MyMessage = "Complain No:" & Me.[Complain_No] & vbcrlf & "Customer Name:" &
Me.[Customer_name]

DoCmd.SendObject acSendNoObject, , , SendTo,SendCc , , MySubject, MyMessage,
False

End Sub
Signature

Hope this helps,

Daniel P

> Hi All, I need assistance with the following code am using to send an email
> from my form.
[quoted text clipped - 21 lines]
> 4- I want the email sent directly as soon the user hits send, right now it
> stops for editing.
khashid - 11 May 2007 14:42 GMT
Thanks very much, trust me i love to go through the help files and it always
help me out but at this moment i really didnt have time to do that.

It worked fine thanks again for your help. One last thing if u dont mind
helping me out is when the email is ready if i cancel the email it gives a
run time error that email was canceled and ask to debug
. How can I have some other error so it would not ask for debug or just
simply not to have error
>You'll need to learn to start using the help a bit more.  It covers the
>parameters for the sendobject method in detail.
[quoted text clipped - 34 lines]
>> 4- I want the email sent directly as soon the user hits send, right now it
>> stops for editing.
Daniel - 11 May 2007 15:43 GMT
This is called error handling.  you need to put in place error handling in
your code (you should do this by default in all your functions...)

Try somthing like the following
Private Sub Command21_Click()
On Error GoTo Command21_Click_Error
Dim SendTo As String
Dim SendCc As String
Dim MySubject  As String
Dim MyMessage As String

SendTo = Me.[Email]
SendCc = "CcRecipientEmailAddressGoesHere"
MySubject = "Complain No :" & Me.[Complain_No]
MyMessage = "Complain No:" & Me.[Complain_No] & vbCrLf & "Customer Name:" & _
           Me.[Customer_name]

DoCmd.SendObject acSendNoObject, , , SendTo, SendCc, , MySubject, MyMessage,
False

Command21_Click_Error:
   If Err.Number = 55 Then
       'Nothing need to be done
   ElseIf Err.Number <> 0 And Err.Number <> 55 Then
       MsgBox "MS Access has generated the following error" & vbCrLf &
vbCrLf & "Error Number: " & _
       Err.Number & vbCrLf & "Error Source: Command21_Click" & vbCrLf & _
       "Error Description: " & Err.Description, vbCritical, "An Error has
Occured!"
   End If
   Exit Sub
End Sub

I used err.number 55 (just as an example) but you'll need to enter the
errornumber you are getting.
Signature

Hope this helps,

Daniel P

> Thanks very much, trust me i love to go through the help files and it always
> help me out but at this moment i really didnt have time to do that.
[quoted text clipped - 42 lines]
> >> 4- I want the email sent directly as soon the user hits send, right now it
> >> stops for editing.
Gary Dolliver - 05 Jun 2007 19:47 GMT
Hello Daniel,
I am hoping you may be able to assist me as well.  I have been going through
the help files and all of these forums and I am stumped on how to set up a
"sendfrom" line.  I am needing this as I will have different emails being
sent from different sections of the program (currently, it will only send
from the default email of Outlook).  I would like certain emails to come from
"customer service" and others from "order confirmation" depending on where
the email is being sent from in the program.
Hope you can help and thanks for your time.
-gary

> This is called error handling.  you need to put in place error handling in
> your code (you should do this by default in all your functions...)
[quoted text clipped - 78 lines]
> > >> 4- I want the email sent directly as soon the user hits send, right now it
> > >> stops for editing.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.