Have found some code that originated from this forum, and have modified it to suit my needs. There's one form with all the information, that has multiple buttons and subsequently multiple functions to generate emails, with each button/email to generate a different format and content. The first use of a button works fine, but trying to use the next button right after does nothing. If you exit the form and re-enter, you can then use the next email button, but that's a pain and the users won't like that. Can anyone help? I've pasted a sample of the code that is being used below, it's duplicated and changed slightly for the other buttons. I currently have the button linked to a macro that does other things like saving, and setting dates and then running the function.
Public Function AckEmailNew()
On Error GoTo Err_cmdMailTicket_Click
Dim varTo As String '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stTicketID As String '-- The ticket ID from form
Dim strSQL As String '-- Create SQL update statement
Dim errLoop As Error
varTo = Me.ClientEmail
stTicketID = Me.STSITicket
stSubject = "Ticket/numéro de référence: " & stTicketID
stText = <<My text goes here>>
'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
I am trying to use the DoCmd.SendObject in a VBA module to send two reports as attachments. I can get this to work just fine with one, but I cannot get this function to send two reports. Is this even possible?
Im using the code below to send information by email. BUT:
I want to send the same information to more than one recipient. can i write more than one address in the SendObject?
What can i do if i do not know prior to sending how many addresses i want to include. (this means that once i might have tosend it to 1, then later to 3, etc...)?
The code is:
Private Sub cmdMailTicket_Click() On Error GoTo Err_cmdMailTicket_Click
Dim stWhere As String '-- Criteria for DLookup Dim varTo As Variant '-- Address for SendObject Dim stText As String '-- E-mail text Dim RecDate As Variant '-- Rec date for e-mail text Dim stSubject As String '-- Subject line of e-mail Dim stTicketID As String '-- The ticket ID from form Dim stWho As String '-- Reference to tblUsers Dim stHelpDesk As String '-- Person who assigned ticket Dim strSQL As String '-- Create SQL update statement Dim errLoop As Error
'-- Combo of names to assign ticket to stWho = Me.cboAssignee stWhere = "tblUsers.strUserID = " & "'" & stWho & "'" '-- Looks up email address from TblUsers varTo = DLookup("[strEMail]", "tblUsers", stWhere)
stText = "You have been assigned a new ticket." & Chr$(13) & Chr$(13) & _ "Ticket number: " & stTicketID & Chr$(13) & _ "This ticket has been assigned to you by: " & strHelpDesk & Chr$(13) & _ "Received Date: " & RecDate & Chr$(13) & Chr$(13) & _ "This is an automated message. Please do not respond to this e-mail."
'Write the e-mail content for sending to assignee DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
'Set the update statement to disable command button 'once e-mail is sent strSQL = "UPDATE tblHelpDeskTickets SET tblHelpDeskTickets.ysnTicketAssigned = -1 " & _ "Where tblHelpDeskTickets.lngTicketID = " & Me.txtTicketID & ";"
On Error GoTo Err_Execute CurrentDb.Execute strSQL, dbFailOnError On Error GoTo 0
'Requery checkbox to show checked 'after update statement has ran 'and disable send mail command button Me.chkTicketAssigned.Requery Me.chkTicketAssigned.SetFocus Me.cmdMailTicket.Enabled = False
' Notify user of any errors that result from ' executing the query. If DBEngine.Errors.Count > 0 Then For Each errLoop In DBEngine.Errors MsgBox "Error number: " & errLoop.Number & vbCr & _ errLoop.Description Next errLoop End If
Hello to all the Users! I am new at Access and new to programming. I have created an Access form that has four labeled control buttons each one with an individuals name. I have the corresponding code:
Private Sub Email_PersonOne_Click() DoCmd.SendObject acSendNoObject, , , "email@example.com", , , "Work Request", "A new work request has been submitted." End Sub
When I have one button and one code the email function works. I want the users to be able to select one out of four people who they want to notify upon completion of the form. So I have four buttons and changed the email address and the names on the buttons but now none of the buttons work. The code is on the same page separated with just a line between each section.
Does this make sense? Any input would be greatly appreciated. Thanks in advance for your time and help. Sincerely, DebraF
I am trying to find a way to use the "DoCmd.SendObject acReport" feature WITHOUT using Outlook. Does anybody know of any code or a setting that will enable me to specify another e-mail program, such a Thunderbird?
I should add that I am using Access 2002, SP3, running in Windows XP Professional, Version 2002, Service Pack 2.
I am perplexed at this command; I am using to send a "form" with 12 fields that user must fill. All is well and it sends email(as it should). However, the email received shows 12 copies of one record. The code is as follows;
All, I'm having a problem in which I can get 3 users on separate PCs to send an email from a form, using the DoCmd.SendObject function, but user #4 can not. All users are on Access 2003 and Outlook 2003. They all use the same front end mdb file. Is there a dependency that SendObject needs, that may not be loaded onto PC #4 ??? I'd also appreciate some comments as to how I may be able to troubleshoot this, if an answer is not readily available. At present User #4 gets the error message, based on the On Error function. Thanks in advance. Allan
I need to use the DoCmd.SendObject method in my code using an email field from a query in the email argument. I have made a query that has 10 or so emails in its results. I will need to use all ten of these emails in the DoCmd.SendObject code argument. Does anyone know how to call the query data into the method?
I use the code below to send a table from my db as an attachment. It works well except on one users pc. When she clicks the button that this is under she gets the following error message "The operation falied due to netowrk or other communication problems. Check your connections and try again.". I'm using Access 2000 and MS Outlook for the email. Is it in the setup of her MS Outlook?
I have a question regarding e-mailing a filtered report from Access 2000.
Does the "DoCmd.SendObject" command allow a filter? I have a report that I open filtered (to one record), and would like to e-mail the single-record filtered report using "DoCmd.SendObject", but have had no success.
Any pointers on how to do this would be greatly appreciated.
Thanks in advance,
Edited by: Bonifaceg on Tue Nov 15 3:02:36 EST 2005.
The code below works for the one email address "Quality Assurance"...but I want to add more email values to SendObject command. If I do this: stEmail = Me.Quality_Assurance_Authorizer.Column(1) And Me.Engineering_Authorizer.Column(1)..... I get a Runtime error '13' Type mismatch. Is there another way of including a series of email values into the SendObject code below? The reason I'm using the value of the column is that sometimes the value may be null if that department doesnt need to be emailed. Thanks for any help.
Private Sub cmdPCAuthSend_Click()
Dim stDocName As String Dim stEmail As String
stDocName = "rptPCAuthReq" stEmail = Me.Quality_Assurance_Authorizer.Column(1) DoCmd.SendObject acSendReport, stDocName, "SnapshotFormat(*.snp)", stEmail, , , "PCA Authorization Request", "Please review this product change and authorize when appropriate."
I have used the DoCmd.SendObject to send confirmation emails with Access97, Access2000. However regardess of the option to Edit (False or True) the email waits for confirmation to send. Using Access XP and/or Access 2003, using YahooMail, using WindowsXP professional. Any way to automate the batch process without viewing, sending each email. Have found no references on KnowledgeBase or this forum. Many thanks
I am using a sendobject method to send an email (w/ attachment) automatically via Outlook. How do I suppress the Yes/No prompt? It says something like "Another program wants to send an email on your behalf..."
When using SendObject is there a way of specifiying the detination name of the Report/Form to differ from the Report/form name?
I have a Report "Quotation" which is the name the attachement appears as in the email.. However It would be nice to change the name to include a sales reference number or Customer Name etc so when it comes back you can locate the right customer Quote without having to open each one...... and/or saving them to file (renaming in the process)
Thoughts/ Suggestions please.
Edited by: itdataservices on Sat Jan 5 17:22:35 EST 2008.
I have an After Update function in a combobox that creates an Outlook email message based on values in form controls. In the email that is created, I simply want to add a carriage return so that the value in the field in green text below starts on a new line rather than immediately after the "...following details:" text. Any help on how to do this is greatly appreciated.
Code: Private Sub cboStaffName_AfterUpdate() On Error GoTo next1 'DoCmd.SetWarnings False DoCmd.SendObject , "", "", "[EarlyWarningEmail,tblEarlyWarningEmail]", "", "", _ "Diarized Corporate Action Expiring within 6 weeks for " & Me.txtPropertyName, _ "A diarized Corporate Action on " & _ Me.txtPropertyName & " (Security Number: " & Me.txtPropertyNumber & ")" & _ "will be expiring within the next 6 weeks. Please set-up a CCA as per the " & _ "following details: " & Me.txtComments
I have two reports (snapshots) that I need to send, by email, at the same time using one command button. Currently I'm using the SendObject macro to email one report. I tried separating the two file names using a semi-colon in the Object Name field but it read it as one file that it could not locate. Is there away to specify an additional snapshot report that would enable me to do this?
After code to set variables for recipient, CC, subject, body text, etc., I have this line of code in the ON CLICK event of a form button. It has always worked flawlessly.
Code:'Insert the e-mail message into the body of the note and wait for the engineer to click SEND. DoCmd.SendObject acSendNoObject, , , strRecip, strCC, , strSubjLine, strEmailMsg, True
We started noticing a few days ago that this has stopped working properly. It will no longer send to multiple recipients. Upon debugging, I find that strCC = "EMAIL1; EMAIL2; EMAIL3" (names changed to protect the innocent ). In the past, my Novel GroupWise 6.5 would fire up, and the CC field would have the three recipients. Now it just has the last one... and only one. I have checked other MDBs that use the SendObject method and they, too, now only send to the last recipient in the list only.
Does anyone have a clue why Access would suddenly start behaving this way? Are there other delimiters I can use to try to "wake it up"? I have tried commas, but no luck... still only the last person.