LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 204
Default Trouble Sending emails

I am using the code below, and it all seems to work fine until it gets to
the '.send' line, and then I get an 'Application or Object defined Error'.
Obviously sending is the key thing here, and I'm pulling my hair out.

I can't see anything wrong with the code unless the numeric equivalent for
olMailItem isn't 0

I really want to get this to work, it's the last peice in a big puzzle for
me.

Thanks

M

===
Sub MailSend() 'SchoolAddress As String)
Dim oLook As Object
Dim oMessage As Object

Dim mTitle As String, mBody As String

' manually set the value of olMail item for late-binding
Const olMailItem As Integer = 0

On Error Resume Next
' Get a reference to the Outlook object model
Set oLook = GetObject(, "Outlook.Application")
If Err.Number = 429 Then 'if it's not already running
Set oLook = CreateObject("Outlook.Application")
End If
On Error GoTo 0

Set oMessage = oLook.CreateItem(olMailItem)

' SchoolMail is declared elsewhere
If SchoolMail = "" Then SchoolMail = "
mTitle = ThisWorkbook.Sheets("Message").Range("B2").Formula
mBody = ThisWorkbook.Sheets("Message").Range("B4").Formula

' Fill and send the message
With oMessage
.To = SchoolMail
.Subject = mTitle
.Body = mBody
.Send ' it just doesn't like this line!
End With

Set oMessage = Nothing

Set oLook = Nothing

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending emails from worksheet Nick Wakeham Excel Discussion (Misc queries) 1 June 28th 06 04:57 PM
Help Sending Emails From Excel mrk0 Excel Discussion (Misc queries) 1 July 6th 05 06:42 PM
Sending Emails according to sheet name Todd Huttenstine[_2_] Excel Programming 1 November 10th 03 04:32 AM
Sending Emails according to sheet name Todd Huttenstine[_2_] Excel Programming 1 November 4th 03 09:25 PM


All times are GMT +1. The time now is 03:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"