ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deferred Mail(2) (https://www.excelbanter.com/excel-programming/305533-deferred-mail-2-a.html)

Don Lloyd

Deferred Mail(2)
 
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 = "
.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 = "
.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



keepITcool

Deferred Mail(2)
 
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

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





keepITcool

Deferred Mail(2)
 

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 :

Cheers and thanks again.
Don

"Don Lloyd" wrote in message
...
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 = "
.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 = "
.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




Amedee Van Gasse[_3_]

Deferred Mail(2)
 
Don Lloyd wrote:

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.

--
Amedee Van Gasse using XanaNews 1.16.3.1
If it has an "X" in the name, it must be Linux?

Don Lloyd

Deferred Mail(2)
 
Cheers and thanks again.
Don

"Don Lloyd" wrote in message
...
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 = "
.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 = "
.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





Tim[_20_]

Deferred Mail(2)
 
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?

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

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




.


keepITcool

Deferred Mail(2)
 

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

Tons of info on www.rondebruin.nl


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


Tim wrote :

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?

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

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





.




All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com