Deferred Mail(2)

D

Don Lloyd

Hi KeepITcool,

Thank you, not only for your reply to my previous post, but also for the
time and effort put into providing two fully coded solutions
With reference to your comments, I'm sorry if I appeared not be appreciate
assistance received from the group - this was not intentional.
I do, however, recall that in my initial post I paid tribute to Ron de
Bruin's and Dick Kusleika's sites, from where I gleaned the initial code and
that I thanked you for the 'snippet' of code that you provided.
If you can bear with me for a while longer, I do have a couple of notes
regarding the code, which is reproduced below.

Sub DeferredMail_Short()
Dim Fname, Sbjct
ActiveSheet.Copy
Fname = "C:\MailTemp\" & "TempMail.xls"
If Dir(Fname) <> "" Then Kill Fname
ActiveWorkbook.SaveAs Fname
ActiveWorkbook.Close False
Sbjct = "Just Testing Short"
With CreateObject("Outlook.Application")
With .CreateItem(0) 'olMailItem
.To = "(e-mail address removed)"
.Subject = Sbjct
. Body = "Notes:"
. Attachments.Add Fname
.Save
. Move .Parent.Session.GetDefaultFolder(16) 'olFolderDrafts
End With
End With
Kill Fname
End Sub

If Outlook is NOT open this works fine eotherwise it fails on line
.Move.Parent.Sessi . . . . .
I'm including the above in case someone else may be tempted to use it as
is - hands up those who haven't 'poached' code from a post!

Sub DeferredMail_Long()
Dim Fname, Sbjct
Dim olApp As Outlook.Application
Dim olFld As Outlook.MAPIFolder
Dim olMsg As Outlook.MailItem
ActiveSheet.Copy
Fname = "C:\MailTemp\" & "TempMail.xls"
If Dir(Fname) <> "" Then Kill Fname
ActiveWorkbook.SaveAs Fname
ActiveWorkbook.Close False
Sbjct = "Just Testing Long"
Set olApp = New Outlook.Application
Set olFld = olApp.Session.GetDefaultFolder(olFolderDrafts)
Set olMsg = olApp.CreateItem(olMailItem)
With olMsg
.To = "(e-mail address removed)"
.Subject = Sbjct
.Body = "Notes:"
.Attachments.Add Fname
.Save
End With
Kill Fname
Set olMsg = Nothing
Set olFld = Nothing
Set olApp = Nothing
End Sub

This has worked fine whether Outlook is open or not. Thank you.
All I need to do now is to convert it to late binding.

Regards,

Don
 
K

keepITcool

Don

next time hit a REPLY button to stay in original thread,
else i'll never notice.. just pure chance i saw this post.
.Save
.Move .Parent.Session.GetDefaultFolder(16) 'olFolderDrafts
End With
End With


change to:

.Save
If ObjPtr(.Parent.Session.Application.ActiveExplorer) = 0 Then
.Move .Parent.Session.GetDefaultFolder(16) 'olFolderDrafts
End If
End With
 
K

keepITcool

Don ..

we're on our way.. at least we're within the thread <g>
next time reply to MY message not your own.
then the system can flag that there is a response to my message and
notify me.



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Don Lloyd wrote :
 
A

Amedee Van Gasse

Don said:
Cheers and thanks again.
Don

Don,

What keepITcool doesn't say:
Dump that virus-infested Outlook Express and start using a *real*
newsreader like XanaNews (see www.newsreaders.com for more info)
Outlook Express grows you bad habits.
 
T

Tim

I have used your code to help with one of my databases.
Thanks for the info. It creates the draft email with
attachment.

How do you have the code send the email also?
 
K

keepITcool

Tim.. iso .Save and .Move do .Send or .Display so the user can press
the send button.

Tons of info on


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tim wrote :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top