Auto Email Problem

jas1159

Registered User.
Local time
Today, 08:52
Joined
Jun 13, 2011
Messages
11
Hi all,

I am trying to use the code below to send an email to more than one person, the email addresses originate from combo and/or text boxes.

So this code works perfectly when sending one email from cbosupplieremail To:

Code:
Private Sub Command32_Click()
Form_frmRaise_Revision1.SetFocus
Form_frmRaise_Revision1.cboSupplierEmail.SetFocus
On Error Resume Next
DoCmd.SendObject acSendForm, "frmRaise_Revision1", "html", Form_frmRaise_Revision1.cboSupplierEmail.Text, , , "Subject", "Email"
On Error GoTo 0
End Sub

According to Access help i can add another To using ; and the following , , is where i can place the CC.

If i replecate the code
Code:
Form_frmRaise_Revision1.cboSupplierEmail.Text

I get an error where i would expect to get the same mail address replicated, I obviously want this pointing to a different source (cboprogrammeEmail.Text) this also causes an error.

I have also tried using
Code:
me.cboSupplierEmail
Code:
cboprogrammeEmail.Text
and it also returns an error :(

I could also create a macro using the build wizard however i am unsure how to link this to the form, my macro returns my code
Code:
Me.txtSupplierEmail
in the To box instead of the email placed at txtSupplierEmail text box,

I cannot simply write the email in as it is not fixed and changes depending on selections made in my form.

I have tried many variations and with knowhere else to turn If somebody knows how to overcome this I would greatly appreciate your help.

Thanks
Jason
 
"an error"? It would help to know which one. If it deals with focus, it's because you're using .Text instead of the default .Value.
 
Sorry the Error for example is when using the following code

Code:
[FONT=Calibri][SIZE=3]DoCmd.SendObject acSendForm, "frmRaise_Revision1", "html", Form_frmRaise_Revision1.cboSupplierEmail.Text: Form_frmRaise_Revision1.cboTEmail.Text , Form_frmRaise_Revision1.cboSupplierEmail.Text, , "Subject", "Email" & vbCr & "Email"[/SIZE][/FONT]

.Text is highlighted on the second To: (Form_frmRaise_Revision1.cboTEmail.Text) as "Invalid use of property" "Compile Error"

If i remove the second To: (Form_frmRaise_Revision1.cboTEmail.Text) it works perfectly with an email address in both the To and the CC rows.

Changing this to .Value had no affect :(

Replacing (Form_frmRaise_Revision1.cboSupplierEmail.Text) with (Form_frmRaise_Revision1.cboTEmail.Text) also creates an issue where when clicking the email button it simply highlights the cboSupplier text box without executing Outlook at all.

This may have something to do with Focus? but as a novice i dont understand how to correct this issue logically. any help is greatly appreciated
 
To do two addresses you'd need to concatenate them:

Forms!FormName.ControlName & "; " & Forms!FormName.OtherControlName
 
Thanks for your input Pbaldy,

I am still struggling though, this code returns the "compile error" "expected end of statement" and highlights the second Form!

Code:
Private Sub Command32_Click()
Form_frmRaise_Revision1.SetFocus
Form_frmRaise_Revision1.cboSupplierEmail.SetFocus
On Error Resume Next
DoCmd.SendObject acSendForm, "frmRaise_Revision1", "html", Forms!frmRaise_Revision1.cboSupplierEmail & "; " Forms!frmRaise_Revision1.cboSupplierEmail, , , "Subject", "Email" & vbCr & "Email"
On Error GoTo 0
End Sub
 
You are missing an ampersand (see Pauls post again).Try this:

Code:
DoCmd.SendObject acSendForm, "frmRaise_Revision1", "html", Forms!frmRaise_Revision1.cboSupplierEmail & "; " [COLOR="Red"]&[/COLOR] Forms!frmRaise_Revision1.cboSupplierEmail, , , "Subject", "Email" & vbCr & "Email"

Chris
 
Hi
try to remove space and make a string in email addresses.

vba.Str(vba.trim(Forms!frmRaise_Revision1.cboSupplierEmail)) & "; " vba.cstr(vba.trim(Forms!frmRaise_Revision1.cboSupplierEmail))
 
I honestly can't thank you enough guys Access seems to be a really powerful tool and I am almost finished with my first database :D

Thanks for your time,
Jason
 

Users who are viewing this thread

Back
Top Bottom