adding additional .values in email error please help

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hi, i have the code below where i have a userform which can be filled out then click on an email button to send to recipitents, but i keep getting errors and will not send, i have 9 different boxes where i want to copy the data from for example textbox1, textbox2, textbox3 and so forth. Pleasd can you help me :) many thanks for your time again.
Code:
Private Sub CommandButton4_Click()

Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String

Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)


        aEmail.Body = "Appt Number: " & Me.TextBox1.Value & Chr(10) & _
                      "MPAN / MPRN: " & Me.TextBox2.Value & Chr(10) & _
                      "Time Slot: " & Me.TextBox3.Value & Chr(10) & _
                      "Address Line 1: " & Me.TextBox4.Value & Chr(10) & _
                      "Address Line 2: " & Me.TextBox5.Value & Chr(10) & _
                      "PostCode: " & Me.TextBox6.Value & Chr(10) & _
                      "Replan / T'band Ext: " & Me.ComboBox1.Value & Chr(10) & _
                      "Reason: " & Me.ComboBox2.Value & Chr(10) & _
                      "Additional Notes: " & Me.TextBox7.Value & Chr(10) & _
        aEmail.Recipients.Add "test.test@test.com"
    
        aEmail.CC = ""
        aEmail.BCC = ""
        aEmail.Subject = "Replan / T'Band Ext"
        aEmail.Send

End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi,


You have added the recipients to the email body.

Code:
 "Additional Notes: " & Me.TextBox7.Value & Chr(10) [COLOR="#FF0000"]& _[/COLOR] 'remove red

        aEmail.Recipients.Add "test.test@test.com"
 
Upvote 0
Glad to help.

You can use also use aEmail.To= "test.test@test.com"
This can be used for multiple recipients separated by a ;
 
Last edited:
Upvote 0
Thank you :) just one more question do you know how i can make the email pop up first insterad of sending automatically, incase it needs to be edited etc :) thank you again
 
Upvote 0
sorry i can't get the above to work this is what i have changed it to (below) it comes up with an error :(, thank you again for all your help

Code:
aEmail.Recipients.To "test.test@test.com"; "test.test@test.com"
 
Upvote 0
Hi,

it's a single string, note quotes. No 'Recipients' in it.
Comment out the send and use .Display instead to view. Then press send as you would normally

Code:
aEmail.To "test.test@test.com; test.test@test.com"

aEmail.Display
' aEmail.Send
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top