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!

email to a speicifc email address

Status
Not open for further replies.

madvalpreston

Technical User
Apr 7, 2011
142
GB
Hi

I want to email a quotation report based on a survey type I have this code.....

Private Sub Command103_Click()

Dim StDocName As String

If MsgBox("This will send Quote to your Client. Continue?", _
vbExclamation + vbYesNoCancel) = vbYes Then

StDocName = "quotedem"
DoCmd.SendObject acSendReport, Combo38.Column(2), acFormatPDF, , "type = '" & Combo38.Column(1) & "' AND IDquote = " & idquote
End If

Set rs = Nothing

End Sub

This selects the correct survey type and creates the correct document, it also goes to email. My problem is I want it to insert the email address of the client in the TO: part.
I ahve the email address in a table called tblcleint.cleintemail and this is linked to the quote.

Any ideas how I can change the code so it can get the correct email address and it appear in the TO:

Thanks
 
The format for the command including optional params is:
Code:
DoCmd.SendObject(ObjectType, ObjectName, OutputFormat, [b]To[/b], Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

Sample code:
Code:
DoCmd.SendObject acSendTable, "Employees", acFormatXLS, _
    "Nancy Davolio; Andrew Fuller", "Joan Weber", , _
    "Current Spreadsheet of Employees", , False

If the recipient names aren't recognized by the mail application, the message isn't sent and an error occurs. If you leave this argument blank, Microsoft Access prompts you for the recipients.

An làmb a bheir, ‘s i a gheibh.
 
Hi



Thanks for the reply, This is what I have;

If I preview the report I use this code and it brings just the one report with the correct quote information.



StDocName = "quotedem"

DoCmd.OpenReport Combo38.Column(2), acPreview, , "type = '" & Combo38.Column(1) & "' AND IDquote = " & idquote




I have made the email address visible in the cboclientid combo box and adjusted my email code as follows




StDocName = "quotedem"

DoCmd.SendObject acSendReport, Combo38.Column(2), acFormatPDF, cboQclientid.Column(3), , , "Asbestos Surveyors UK Quotation", , , "type = '" & Combo38.Column(1) & "' AND IDquote = " & idquote

This now works EXCEPT, it now makes the report for all quotes with that type of survey type, so for example we have 2 quotes with survey type Combination, so it creates the PDF attachment and then it as 2 full reports (as one). I only need the quote it relates to on the screen (I am mailing by button on the screen)...



Any ideas on what is incorrect on the code....





Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top