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
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