View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Todd Huttenstine[_2_] Todd Huttenstine[_2_] is offline
external usenet poster
 
Posts: 237
Default Conditional Sheet Attachment

Combobox1 is populated with sheet names. The user will
select a sheetname from the combobox.

What is the code that will attach the sheet that is in
combobox1 and bring up an outlook email dialog box. I
want the email dialog box to have the subject of "Stats"
and an empty body and To address field.

For example, the user clicks the combobox and selects the
value "Todd Huttenstine". When the code is run, it must
attach worksheet "Todd Huttenstine" to the email.

Below is the code I have so far, but I want my email
address taken out. When I take it out I get an error.

Can anyone please show me the modified code to perform the
task?



Option Explicit
Private Sub CommandButton1_Click()
Dim objSession As Object, objMessage As Object,
objOneRecip As Object
Set objSession = CreateObject("MAPI.Session")
objSession.Logon
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = "Stats"
objMessage.Text = ""
Set objOneRecip = objMessage.Recipients.Add
objOneRecip.Name = "
objOneRecip.Type = 1
objOneRecip.Resolve
objMessage.Send showDialog:=True
objSession.Logoff


End Sub

Thank you

Todd Huttenstine