Tom.......that pesky E-mail thingy


Posted by Ian on September 05, 2001 1:37 AM

Thought I'd start again up here:

I can't seem to get this to work, I've completely messed things around but nothing. As you'll see nothing is in the right place, perhaps I should have said that I'm pretty crap at this stuff.
Couldn't workout what you ment by placing something after the With thing, what With thing.
help would be fantastic, cheers Ian

Private Sub CommandButton1_Click()

Dim OLook As Object 'Outlook.Application
Dim Mitem As Object 'Outlook.Mailitem
Dim SendAnEmail As Boolean
Dim fname As Object
Dim otlAttach As Object

Set OLook = CreateObject("Outlook.Application")
Set Mitem = OLook.createitem(0)

Set fname = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

Mitem.to = "ian.mcconnell@sitel.co.uk"
Mitem.Subject = "Here's the figure's for the week commencing " _
& Cells(4, 2).Value
Mitem.body = "hello"
Mitem.Attachments.Add fname
Mitem.send
Set otlAttach = Nothing

End Sub

Posted by Dax on September 05, 2001 2:18 AM

Morning,

The main problem with your code is that you are trying to assign a string (the workbook path and name) to an object variable (fname). Try these changes to your code:-

Private Sub CommandButton1_Click()

Dim OLook As Object 'Outlook.Application
Dim Mitem As Object 'Outlook.Mailitem
Dim SendAnEmail As Boolean
Dim fname As String
Dim otlAttach As Object

Set OLook = CreateObject("Outlook.Application")
Set Mitem = OLook.createitem(0)

fname = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

Mitem.to = "ian.mcconnell@sitel.co.uk"
Mitem.Subject = "Here's the figure's for the week commencing " _
& Cells(4, 2).Value
Mitem.body = "hello"
Mitem.Attachments.Add fname
Mitem.send
Set otlAttach = Nothing

End Sub

Regards,
Dax.


Posted by Tom Urtis on September 05, 2001 7:42 AM

Thanks Dax




Posted by Ian on September 06, 2001 3:36 AM

Thanks Dax and Tom works dandy now