Email creation based on response

Dazlancs

New Member
Joined
Sep 10, 2011
Messages
28
Hi all,

following on from a thread yesterday i need further assisance.

If i get a question asking do you want to send email and the response is "yes", i want outlook to display a mail however if it's "no" then i want it to end (as per code below, it's the last question):

Excel 2010 - to be backwards compatible to 2007

Rich (BB code):
q9 = InputBox("Q9: Do you want to activate messaging?", "msg", "Yes/No")
Worksheets("Response").Cells(Range("msg").Row, Range("msg").Column).Value = q9
 
If q9 = "no" Then
    q10 = InputBox("Q10: Do you want to send the email?", "email", "Yes/No")
    Worksheets("Response").Cells(Range("email").Row, Range("email").Column).Value = q10
End If
If q10 = "yes" Then
Email_Subject = "Test"
Email_Send_From = "darren@isp.com"
Email_Send_To = "testacct1@isp.com"
Email_Bcc = "testacct2@isp.com"
Email_Body = "Hello - " & vbCr & vbCr & "This is a test." & vbCr & vbCr & "Thanks," & vbCr & vbCr & "darren"
    Set Mail_Object = CreateObject("Outlook.Application")
    Set Mail_Single = Mail_Object.CreateItem(0)
    With Mail_Single
    .Subject = Email_Subject
    .To = Email_Send_To
    .cc = Email_Cc
    .BCC = Email_Bcc
    .Body = Email_Body
    .display
 
End If
If q9 = "yes" Then
    Dim ie As Object
    Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
    ie.NAVIGATE "http://website.com/"
    ie.Visible = True
    While ie.busy
    DoEvents
    Wend
 
    q10 = InputBox("Q10: Do you want to send the email?", "email", "Yes/No")
    Worksheets("Response").Cells(Range("email").Row, Range("email").Column).Value = q10
 
End If
Sheets("Response").Select
End Sub

Thanks in advance for your expertise.

Darren
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,507
Messages
6,179,181
Members
452,893
Latest member
denay

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