e-mail not sending (1 Viewer)

CJBIRKIN

Drink!
Local time
Today, 07:05
Joined
May 10, 2002
Messages
256
Hello

Can anyone help please!. I'm populating an excel spreadsheet with 2 queries, saving it, and then calling this function to e-mail the spreadsheet as an attachment. Strangley when the line ".Attachments = XLSReportPath" has executed Access skips out of the function and back to the main sub. Consequently the e-mail is not sent. Any ideas ?


Thanks Chris

Private Function EMailReport(XLSReportPath As String, Addressee As String, Address As String)

Dim olkapps As Outlook.Application
Dim olknamespaces As Outlook.NameSpace
Dim objmailitems As Outlook.MailItem

Set olkapps = New Outlook.Application
Set olknamespaces = GetNamespace("MAPI")
Set objmailitems = olkapps.CreateItem(olMailItem)

With objmailitems
.To = Addressee
.Subject = "KH07 & Census for " & Format(DateAdd("m", -1, Now()), "MMMM YYYY")
.Body = "Hello" & vbCrLf & "Please find enclosed the KH07 & Census for " & Format(DateAdd("m", -1, Now()), "MMMM YYYY")
.Importance = olImportanceHigh
.Attachments = XLSReportPath
.Send


End With

Set objmailitems = Nothing
Set olknamespaces = Nothing
Set olkapps = Nothing

End Function
 

ColinEssex

Old registered user
Local time
Today, 07:05
Joined
Feb 22, 2002
Messages
9,116
Ahhhhh yes.........the famous KH07 !!!! that'll be the problem - it has to be waiting list figures - obviously the KH07 is showing too many over 15 months;)

Seriously though, does it all work if you type in the path instead of having the variable?


Col
:cool:
 

CJBIRKIN

Drink!
Local time
Today, 07:05
Joined
May 10, 2002
Messages
256
Hello

I guess from that comment you have been enjoying a stay at
Mr Milburns fun factory.

As for 15 month, no problems on that front we worring about 12 months at end of March!

I have been testing this and for some reason when it tries to execute .Attachments = "c:\monthly\waitlist\TESTKH07&CENSUSJan2003" it drops out of the function. Other than that it works fine.

any ideas?

Chris
 

ColinEssex

Old registered user
Local time
Today, 07:05
Joined
Feb 22, 2002
Messages
9,116
Hi Chris

Yep - I did 9 years of what you're doing, but write databases now (still NHS) so I'm not familiar with the current target times.

I'm not sure about your problem either, I'll have a scout around, I'm sure I did something for our information bods where they can attach and email out etc. (I think it was A/E wait times, almost as good a joke as the W/L times!!)

Col
:cool:
 

ColinEssex

Old registered user
Local time
Today, 07:05
Joined
Feb 22, 2002
Messages
9,116
Hi Again

I've had a butchers at the Info bods Db and I used the SendObject method.

Have a look in Access help on SendObject - it may (or may not) help you.

Col
:cool:
 

CJBIRKIN

Drink!
Local time
Today, 07:05
Joined
May 10, 2002
Messages
256
Yes unfortunatley i am information but i spend most of my time writtings db's and apps for the others this one's got me stumped. i tried the help but i couldn't get any of that to work either as i tried creating and attachments object but it bombed out there as well. Oh well back to the drawing board.

thanks for your help

Chris
 

ColinEssex

Old registered user
Local time
Today, 07:05
Joined
Feb 22, 2002
Messages
9,116
Post back tomorrow if you're still stuck. I have to go out now.

Col
:cool:
 

CJBIRKIN

Drink!
Local time
Today, 07:05
Joined
May 10, 2002
Messages
256
fixed it.

The path was incorrect i had left of .xls !

doh!

thanks chris
 

Users who are viewing this thread

Top Bottom