dbTalk Databases Forums  

Move Email from Drafts to Outbox

comp.databases.ms-access comp.databases.ms-access


Discuss Move Email from Drafts to Outbox in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Darlington
 
Posts: n/a

Default Move Email from Drafts to Outbox - 11-17-2011 , 11:30 PM






I'm using Access 2002 and 2010 and have a VBA routine which happily creates
multiple emails and dumps them into the client's Drafts folder in Outlook.
My theory was that the client should open Outlook and actually check the
email before moving it to the Outbox from within Outlook.
The client now wants to include a facility to press a button and send the
email from the Drafts folder from within Access.
Has anyone done something similar?
--
Bob Darlington
Brisbane

Reply With Quote
  #2  
Old   
Arvin Meyer
 
Posts: n/a

Default Re: Move Email from Drafts to Outbox - 11-18-2011 , 04:39 AM






To the best of my knowledge, you cannot send directly from the Drafts
folder. I'm not familiar enough with the Outlook Object Model to know if it
is possible to move the email to the Outbox in VBA code, but I imagine it
can be done.

If the client is not going to inspect the emails first, then there's no
reason to put them in Drafts, or you can use the .Display property to show
the email. Otherwise, just send them using .Send.

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://access.mvps.org
Co-author: "Access Solutions", published by Wiley



"Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote

Quote:
I'm using Access 2002 and 2010 and have a VBA routine which happily
creates multiple emails and dumps them into the client's Drafts folder in
Outlook.
My theory was that the client should open Outlook and actually check the
email before moving it to the Outbox from within Outlook.
The client now wants to include a facility to press a button and send the
email from the Drafts folder from within Access.
Has anyone done something similar?
--
Bob Darlington
Brisbane

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Move Email from Drafts to Outbox - 11-18-2011 , 07:01 AM



On 18/11/2011 10:39:04, "Arvin Meyer" wrote:
Quote:
To the best of my knowledge, you cannot send directly from the Drafts
folder. I'm not familiar enough with the Outlook Object Model to know if
it is possible to move the email to the Outbox in VBA code, but I imagine
it can be done.

If the client is not going to inspect the emails first, then there's no
reason to put them in Drafts, or you can use the .Display property to show
the email. Otherwise, just send them using .Send.

Don't know if this will help

Function ZZMoveDLs(FromFolder As String, ToFolder As String, ToSavedDistList
As Boolean) As Integer

'?ZZMoveDls("Yacht Club", "SavedDistributionLists", True) Saves Distribution
List '?ZZMoveDls("SavedDistributionLists", "Yacht Club", False) selectively
restores Distribution List

Dim OlApp As New Outlook.Application
Dim OlNS As Outlook.NameSpace
Dim OlContacts As Outlook.MAPIFolder
Dim OlFromFolder As Outlook.MAPIFolder
Dim OlToFolder As Outlook.MAPIFolder
Dim OlDL As Outlook.DistListItem
Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer

SysCmd acSysCmdSetStatus, "Saving Distribution Lists"
Set OlNS = OlApp.GetNamespace("MAPI")
Set Set OlContacts =
OlNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderContacts) Set
OlFromFolder = ZZFindFolder(FromFolder) If OlFromFolder.Name = "Contacts"
Then ' Not found MsgBox "The Address Book " & FromFolder & " can not be
found", vbCritical GoTo MoveDls_Exit
End If

Set OlToFolder = ZZFindFolder(ToFolder)
If OlToFolder.Name = "Contacts" Then ' Not found
MsgBox MsgBox "The Address Book " & ToFolder & " can not be found",
vbCritical GoTo MoveDls_Exit
End If

j = 1 ' Folders found OK
If ToSavedDistList = True Then ' Save Distribution List
m = Len(FromFolder) ' len("Yacht Club")
For i = OlFromFolder.Items.Count To 1 Step -1
If TypeName(OlFromFolder.Items.Item(i)) = "DistListItem" Then
l l = OlFromFolder.Items.Count - i + 1 ' Seems to work backwards
k = Len(Str(l))
Set OlDL = OlFromFolder.Items.Item(i)
If If Left(OlDL.DLName, 7 + m) <> FromFolder & " Group " Then ' Dont save
'Yacht Club Group' OlFromFolder.Items.Item(i).Move OlToFolder
j = j + 1
End If
End If
Next i
Else Else ' Restore distribution list
m = Len(ToFolder) ' len("Yacht Club")
For i = OlFromFolder.Items.Count To 1 Step -1
l l = OlFromFolder.Items.Count - i + 1 ' Seems to work backwards
k = Len(Str(l))
If TypeName(OlFromFolder.Items.Item(i)) = "DistListItem" Then
Set OlDL = OlFromFolder.Items.Item(i)
If If Left(OlDL.DLName, m + k + 11) <> ToFolder & " Group " & CStr(l) & " to:
" Then OlFromFolder.Items.Item(i).Move OlToFolder
End If
j = j + 1
End If
Next i
End If

MoveDls_Exit:
Set OlDL = Nothing
Set OlFromFolder = Nothing
Set OlNS = Nothing
Set OlApp = Nothing
ZZMoveDLs = j ' Output
SysCmd acSysCmdClearStatus
Exit Function

MoveDls_Err:
MsgBox Err.Description, vbCritical
Resume MoveDls_Exit

End Function

I think this is the relevant line
OlFromFolder.Items.Item(i).Move OlToFolder

Phil

Reply With Quote
  #4  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Move Email from Drafts to Outbox - 11-20-2011 , 06:54 PM



Thanks Arvin.
The problem is that different clients using my applications want different
things.
And this particular client is too important for me to ignore its wishes.

"Arvin Meyer" <arvinm (AT) invalid (DOT) org> wrote

Quote:
To the best of my knowledge, you cannot send directly from the Drafts
folder. I'm not familiar enough with the Outlook Object Model to know if
it is possible to move the email to the Outbox in VBA code, but I imagine
it can be done.

If the client is not going to inspect the emails first, then there's no
reason to put them in Drafts, or you can use the .Display property to show
the email. Otherwise, just send them using .Send.

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://access.mvps.org
Co-author: "Access Solutions", published by Wiley



"Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote in message
news:4ec5ec9b$0$2444$afc38c87 (AT) news (DOT) optusnet.com.au...
I'm using Access 2002 and 2010 and have a VBA routine which happily
creates multiple emails and dumps them into the client's Drafts folder in
Outlook.
My theory was that the client should open Outlook and actually check the
email before moving it to the Outbox from within Outlook.
The client now wants to include a facility to press a button and send the
email from the Drafts folder from within Access.
Has anyone done something similar?
--
Bob Darlington
Brisbane



Reply With Quote
  #5  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Move Email from Drafts to Outbox - 11-20-2011 , 08:34 PM



Thanks Phil.
That was it.

--
Bob Darlington
Brisbane
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 18/11/2011 10:39:04, "Arvin Meyer" wrote:
To the best of my knowledge, you cannot send directly from the Drafts
folder. I'm not familiar enough with the Outlook Object Model to know if
it is possible to move the email to the Outbox in VBA code, but I imagine
it can be done.

If the client is not going to inspect the emails first, then there's no
reason to put them in Drafts, or you can use the .Display property to
show
the email. Otherwise, just send them using .Send.


Don't know if this will help

Function ZZMoveDLs(FromFolder As String, ToFolder As String,
ToSavedDistList
As Boolean) As Integer

'?ZZMoveDls("Yacht Club", "SavedDistributionLists", True) Saves
Distribution
List '?ZZMoveDls("SavedDistributionLists", "Yacht Club", False)
selectively
restores Distribution List

Dim OlApp As New Outlook.Application
Dim OlNS As Outlook.NameSpace
Dim OlContacts As Outlook.MAPIFolder
Dim OlFromFolder As Outlook.MAPIFolder
Dim OlToFolder As Outlook.MAPIFolder
Dim OlDL As Outlook.DistListItem
Dim i As Integer, j As Integer, k As Integer, l As Integer, m As
Integer

SysCmd acSysCmdSetStatus, "Saving Distribution Lists"
Set OlNS = OlApp.GetNamespace("MAPI")
Set Set OlContacts =
OlNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderContacts) Set
OlFromFolder = ZZFindFolder(FromFolder) If OlFromFolder.Name = "Contacts"
Then ' Not found MsgBox "The Address Book " & FromFolder & " can not be
found", vbCritical GoTo MoveDls_Exit
End If

Set OlToFolder = ZZFindFolder(ToFolder)
If OlToFolder.Name = "Contacts" Then ' Not found
MsgBox MsgBox "The Address Book " & ToFolder & " can not be found",
vbCritical GoTo MoveDls_Exit
End If

j = 1 ' Folders found OK
If ToSavedDistList = True Then ' Save Distribution
List
m = Len(FromFolder) ' len("Yacht Club")
For i = OlFromFolder.Items.Count To 1 Step -1
If TypeName(OlFromFolder.Items.Item(i)) = "DistListItem" Then
l l = OlFromFolder.Items.Count - i + 1 ' Seems to work backwards
k = Len(Str(l))
Set OlDL = OlFromFolder.Items.Item(i)
If If Left(OlDL.DLName, 7 + m) <> FromFolder & " Group " Then ' Dont save
'Yacht Club Group' OlFromFolder.Items.Item(i).Move OlToFolder
j = j + 1
End If
End If
Next i
Else Else ' Restore distribution list
m = Len(ToFolder) ' len("Yacht Club")
For i = OlFromFolder.Items.Count To 1 Step -1
l l = OlFromFolder.Items.Count - i + 1 ' Seems to work backwards
k = Len(Str(l))
If TypeName(OlFromFolder.Items.Item(i)) = "DistListItem" Then
Set OlDL = OlFromFolder.Items.Item(i)
If If Left(OlDL.DLName, m + k + 11) <> ToFolder & " Group " & CStr(l) & "
to:
" Then OlFromFolder.Items.Item(i).Move OlToFolder
End If
j = j + 1
End If
Next i
End If

MoveDls_Exit:
Set OlDL = Nothing
Set OlFromFolder = Nothing
Set OlNS = Nothing
Set OlApp = Nothing
ZZMoveDLs = j ' Output
SysCmd acSysCmdClearStatus
Exit Function

MoveDls_Err:
MsgBox Err.Description, vbCritical
Resume MoveDls_Exit

End Function

I think this is the relevant line
OlFromFolder.Items.Item(i).Move OlToFolder

Phil

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.