Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sending emails from worksheet | Excel Discussion (Misc queries) | |||
Help Sending Emails From Excel | Excel Discussion (Misc queries) | |||
Sending Emails according to sheet name | Excel Programming | |||
Sending Emails according to sheet name | Excel Programming |