Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Redemption emails to draft folder

Geek News

Redemption emails to draft folder
simonkue 6/14/2006 1:09:02 PM
I have a VB6 pgm that used to generate outlook e-mails correctly prior to
v2002. Now I need Redemption. I can generate the e-mail but it goes to the
drafts folder and not directly to the Outbox. I can copy from Draft to Outbox
but it is not ready to be sent and needs to be individually entered and sent.
I should be able to generate e-mail directly to the Outbox. What am I doing
wrong?
Using Win2k and XP, Outlook 2k and 2002 - same results.
The following code is a routine called for each e-mail so that there is only
1 To and no cc or bcc per e-mail.

Function CreateMail(xsRecip As Variant, xsSubject As String, xsMsg As
String, _
Optional xsAttachments As String) As Boolean

' Create new e-mail

Dim xvRecip As Variant
Dim xvAttach As Variant
Dim xbResolveOK As Boolean
Dim xnLen As Integer

Dim oMailItem As Object
Dim oMail As Object

Dim myNameSpace As NameSpace
Dim myFolder As Object

Dim SafeItem, oItem

On Error GoTo CreateMail_Err

' Get the message text. If xsMsg=Clipboard, then that is where the text is
If xsMsg = "Clipboard" Then
xsMsg = Clipboard.GetText
End If

xnLen = Len(xsMsg) + 1

Set Application = CreateObject("Outlook.Application")
Set myNameSpace = Application.GetNamespace("MAPI")
myNameSpace.Logon
Set myFolder = myNameSpace.GetDefaultFolder(4) 'olFolderOutbox

Set SafeItem = CreateObject("Redemption.SafeMailItem")
Set oItem = Application.CreateItem(olMailItem)
SafeItem.Item = oItem

With SafeItem
.Item = oItem
.Recipients.Add xsRecip
xbResolveOK = .Recipients.ResolveAll

' Note that the attachment must have the full file path. File name alone
isn't good enough!

If Not IsMissing(xsAttachments) And xsAttachments <> "" Then
.Attachments.Add xsAttachments, olByValue, xnLen, "Enclosed file"
End If
.Subject = xsSubject
.Body = xsMsg
If xbResolveOK Then
On Error GoTo 0
.Save
.ExpiryTime = .CreationTime
' .Send
.CopyTo myFolder
Else
MsgBox "Unable to resolve recipient. Please check " & xsRecip
.Display
End If
End With

CreateMail = True

'Set oMailItem = Nothing
'Set orSafeMailItem = Nothing
'Set xgolApp = Nothing
'
CreateMail_End:
Exit Function

CreateMail_Err:
CreateMail = False
Resume CreateMail_End
End Function


Re: Redemption emails to draft folder
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/14/2006 1:35:24 PM
That's what always happens, don't worry about it. The mail item doesn't have
to be in Outbox to go out. Just call Send on the item and then if you want
it out immediately either call DeliverNow or use code to click the
Send/Receive or Send/Receive All menu commands. There's a sample for that in
the Redemption FAQ.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"simonkue" <simonkue[ at ]discussions.microsoft.com> wrote in message
news:98336534-30A7-45DD-A6F6-2E4BA0CDB985[ at ]microsoft.com...
[Quoted Text]
>I have a VB6 pgm that used to generate outlook e-mails correctly prior to
> v2002. Now I need Redemption. I can generate the e-mail but it goes to the
> drafts folder and not directly to the Outbox. I can copy from Draft to
> Outbox
> but it is not ready to be sent and needs to be individually entered and
> sent.
> I should be able to generate e-mail directly to the Outbox. What am I
> doing
> wrong?
> Using Win2k and XP, Outlook 2k and 2002 - same results.
> The following code is a routine called for each e-mail so that there is
> only
> 1 To and no cc or bcc per e-mail.
>
> Function CreateMail(xsRecip As Variant, xsSubject As String, xsMsg As
> String, _
> Optional xsAttachments As String) As Boolean
>
> ' Create new e-mail
>
> Dim xvRecip As Variant
> Dim xvAttach As Variant
> Dim xbResolveOK As Boolean
> Dim xnLen As Integer
>
> Dim oMailItem As Object
> Dim oMail As Object
>
> Dim myNameSpace As NameSpace
> Dim myFolder As Object
>
> Dim SafeItem, oItem
>
> On Error GoTo CreateMail_Err
>
> ' Get the message text. If xsMsg=Clipboard, then that is where the text
> is
> If xsMsg = "Clipboard" Then
> xsMsg = Clipboard.GetText
> End If
>
> xnLen = Len(xsMsg) + 1
>
> Set Application = CreateObject("Outlook.Application")
> Set myNameSpace = Application.GetNamespace("MAPI")
> myNameSpace.Logon
> Set myFolder = myNameSpace.GetDefaultFolder(4) 'olFolderOutbox
>
> Set SafeItem = CreateObject("Redemption.SafeMailItem")
> Set oItem = Application.CreateItem(olMailItem)
> SafeItem.Item = oItem
>
> With SafeItem
> .Item = oItem
> .Recipients.Add xsRecip
> xbResolveOK = .Recipients.ResolveAll
>
> ' Note that the attachment must have the full file path. File name alone
> isn't good enough!
>
> If Not IsMissing(xsAttachments) And xsAttachments <> "" Then
> .Attachments.Add xsAttachments, olByValue, xnLen, "Enclosed file"
> End If
> .Subject = xsSubject
> .Body = xsMsg
> If xbResolveOK Then
> On Error GoTo 0
> .Save
> .ExpiryTime = .CreationTime
> ' .Send
> .CopyTo myFolder
> Else
> MsgBox "Unable to resolve recipient. Please check " & xsRecip
> .Display
> End If
> End With
>
> CreateMail = True
>
> 'Set oMailItem = Nothing
> 'Set orSafeMailItem = Nothing
> 'Set xgolApp = Nothing
> '
> CreateMail_End:
> Exit Function
>
> CreateMail_Err:
> CreateMail = False
> Resume CreateMail_End
> End Function
>
>

RE: Redemption emails to draft folder
simonkue 6/14/2006 7:58:02 PM
Sorry - posted this duplicate entry by mistake! Please ignore this copy

"simonkue" wrote:

[Quoted Text]
> I have a VB6 pgm that used to generate outlook e-mails correctly prior to
> v2002. Now I need Redemption. I can generate the e-mail but it goes to the
> drafts folder and not directly to the Outbox. I can copy from Draft to Outbox
> but it is not ready to be sent and needs to be individually entered and sent.
> I should be able to generate e-mail directly to the Outbox. What am I doing
> wrong?
> Using Win2k and XP, Outlook 2k and 2002 - same results.
> The following code is a routine called for each e-mail so that there is only
> 1 To and no cc or bcc per e-mail.
>
> Function CreateMail(xsRecip As Variant, xsSubject As String, xsMsg As
> String, _
> Optional xsAttachments As String) As Boolean
>
> ' Create new e-mail
>
> Dim xvRecip As Variant
> Dim xvAttach As Variant
> Dim xbResolveOK As Boolean
> Dim xnLen As Integer
>
> Dim oMailItem As Object
> Dim oMail As Object
>
> Dim myNameSpace As NameSpace
> Dim myFolder As Object
>
> Dim SafeItem, oItem
>
> On Error GoTo CreateMail_Err
>
> ' Get the message text. If xsMsg=Clipboard, then that is where the text is
> If xsMsg = "Clipboard" Then
> xsMsg = Clipboard.GetText
> End If
>
> xnLen = Len(xsMsg) + 1
>
> Set Application = CreateObject("Outlook.Application")
> Set myNameSpace = Application.GetNamespace("MAPI")
> myNameSpace.Logon
> Set myFolder = myNameSpace.GetDefaultFolder(4) 'olFolderOutbox
>
> Set SafeItem = CreateObject("Redemption.SafeMailItem")
> Set oItem = Application.CreateItem(olMailItem)
> SafeItem.Item = oItem
>
> With SafeItem
> .Item = oItem
> .Recipients.Add xsRecip
> xbResolveOK = .Recipients.ResolveAll
>
> ' Note that the attachment must have the full file path. File name alone
> isn't good enough!
>
> If Not IsMissing(xsAttachments) And xsAttachments <> "" Then
> .Attachments.Add xsAttachments, olByValue, xnLen, "Enclosed file"
> End If
> .Subject = xsSubject
> .Body = xsMsg
> If xbResolveOK Then
> On Error GoTo 0
> .Save
> .ExpiryTime = .CreationTime
> ' .Send
> .CopyTo myFolder
> Else
> MsgBox "Unable to resolve recipient. Please check " & xsRecip
> .Display
> End If
> End With
>
> CreateMail = True
>
> 'Set oMailItem = Nothing
> 'Set orSafeMailItem = Nothing
> 'Set xgolApp = Nothing
> '
> CreateMail_End:
> Exit Function
>
> CreateMail_Err:
> CreateMail = False
> Resume CreateMail_End
> End Function
>
>
Re: Redemption emails to draft folder
simonkue 6/14/2006 8:00:02 PM
Ken, Thanks for your answer. I've tested this and this part is fine.
Has it always been the case that e-mails can be sent from "anywhere" in
Outlook? I assumed that they had to be in the Outbox to be picked up.

"Ken Slovak - [MVP - Outlook]" wrote:

[Quoted Text]
> That's what always happens, don't worry about it. The mail item doesn't have
> to be in Outbox to go out. Just call Send on the item and then if you want
> it out immediately either call DeliverNow or use code to click the
> Send/Receive or Send/Receive All menu commands. There's a sample for that in
> the Redemption FAQ.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "simonkue" <simonkue[ at ]discussions.microsoft.com> wrote in message
> news:98336534-30A7-45DD-A6F6-2E4BA0CDB985[ at ]microsoft.com...
> >I have a VB6 pgm that used to generate outlook e-mails correctly prior to
> > v2002. Now I need Redemption. I can generate the e-mail but it goes to the
> > drafts folder and not directly to the Outbox. I can copy from Draft to
> > Outbox
> > but it is not ready to be sent and needs to be individually entered and
> > sent.
> > I should be able to generate e-mail directly to the Outbox. What am I
> > doing
> > wrong?
> > Using Win2k and XP, Outlook 2k and 2002 - same results.
> > The following code is a routine called for each e-mail so that there is
> > only
> > 1 To and no cc or bcc per e-mail.
> >
> > Function CreateMail(xsRecip As Variant, xsSubject As String, xsMsg As
> > String, _
> > Optional xsAttachments As String) As Boolean
> >
> > ' Create new e-mail
> >
> > Dim xvRecip As Variant
> > Dim xvAttach As Variant
> > Dim xbResolveOK As Boolean
> > Dim xnLen As Integer
> >
> > Dim oMailItem As Object
> > Dim oMail As Object
> >
> > Dim myNameSpace As NameSpace
> > Dim myFolder As Object
> >
> > Dim SafeItem, oItem
> >
> > On Error GoTo CreateMail_Err
> >
> > ' Get the message text. If xsMsg=Clipboard, then that is where the text
> > is
> > If xsMsg = "Clipboard" Then
> > xsMsg = Clipboard.GetText
> > End If
> >
> > xnLen = Len(xsMsg) + 1
> >
> > Set Application = CreateObject("Outlook.Application")
> > Set myNameSpace = Application.GetNamespace("MAPI")
> > myNameSpace.Logon
> > Set myFolder = myNameSpace.GetDefaultFolder(4) 'olFolderOutbox
> >
> > Set SafeItem = CreateObject("Redemption.SafeMailItem")
> > Set oItem = Application.CreateItem(olMailItem)
> > SafeItem.Item = oItem
> >
> > With SafeItem
> > .Item = oItem
> > .Recipients.Add xsRecip
> > xbResolveOK = .Recipients.ResolveAll
> >
> > ' Note that the attachment must have the full file path. File name alone
> > isn't good enough!
> >
> > If Not IsMissing(xsAttachments) And xsAttachments <> "" Then
> > .Attachments.Add xsAttachments, olByValue, xnLen, "Enclosed file"
> > End If
> > .Subject = xsSubject
> > .Body = xsMsg
> > If xbResolveOK Then
> > On Error GoTo 0
> > .Save
> > .ExpiryTime = .CreationTime
> > ' .Send
> > .CopyTo myFolder
> > Else
> > MsgBox "Unable to resolve recipient. Please check " & xsRecip
> > .Display
> > End If
> > End With
> >
> > CreateMail = True
> >
> > 'Set oMailItem = Nothing
> > 'Set orSafeMailItem = Nothing
> > 'Set xgolApp = Nothing
> > '
> > CreateMail_End:
> > Exit Function
> >
> > CreateMail_Err:
> > CreateMail = False
> > Resume CreateMail_End
> > End Function
> >
> >
>
>
Re: Redemption emails to draft folder
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/14/2006 8:45:13 PM
Outlook places them in Outbox, Redemption and some other API's place them in
Drafts and they move through Outbox so quickly you don't see them <shrug>.
It doesn't prevent things from working correctly.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"simonkue" <simonkue[ at ]discussions.microsoft.com> wrote in message
news:414B2364-7A45-465F-BA7B-317ACEDC4D1C[ at ]microsoft.com...
[Quoted Text]
> Ken, Thanks for your answer. I've tested this and this part is fine.
> Has it always been the case that e-mails can be sent from "anywhere" in
> Outlook? I assumed that they had to be in the Outbox to be picked up.

Re: Redemption emails to draft folder
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 6/14/2006 9:36:03 PM
Actually Redemption does not even try to move the message since doing so
will result in a ghost message. And by default Outlook creates new messages
in the Drafts folder.
You can explicitly move the item *before* using Redemption:

Set oItem = Application.CreateItem(olMailItem)
set oItem = oItem.Move(myFolder)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> wrote in message
news:uM7dzN$jGHA.4040[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text]
> Outlook places them in Outbox, Redemption and some other API's place them
> in Drafts and they move through Outbox so quickly you don't see them
> <shrug>. It doesn't prevent things from working correctly.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "simonkue" <simonkue[ at ]discussions.microsoft.com> wrote in message
> news:414B2364-7A45-465F-BA7B-317ACEDC4D1C[ at ]microsoft.com...
>> Ken, Thanks for your answer. I've tested this and this part is fine.
>> Has it always been the case that e-mails can be sent from "anywhere" in
>> Outlook? I assumed that they had to be in the Outbox to be picked up.
>


Re: Redemption emails to draft folder
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 6/14/2006 9:39:12 PM
So, what is it with moving items out of Drafts? I've heard of other people encountering these "ghost" messages when they try to do that.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> wrote in message news:u38Puo$jGHA.4748[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
> Actually Redemption does not even try to move the message since doing so
> will result in a ghost message. And by default Outlook creates new messages
> in the Drafts folder.

Re: Redemption emails to draft folder
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 6/14/2006 10:52:08 PM
That happens if you use the old instance of the mesage that was supposed to
be immediately released:

OldMessage.Move(SomeFolder)
OldMessage.Whatever
OldMessage.Save

Boom! You got a ghost message in the old parent folder. Don't know if that
happens 100% of the time, but it certainly does happen. The right way to do
that is

set NewMessage = OldMessage.Move(SomeFolder)
NewMessage.Whatever
NewMessage.Save

And Redemption cannot do this silently under the covers because it has no
way of replacing the reference to the old message in the calling code. The
caller must do that explicitly first.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> wrote in message
news:uflVcv$jGHA.3816[ at ]TK2MSFTNGP02.phx.gbl...
So, what is it with moving items out of Drafts? I've heard of other people
encountering these "ghost" messages when they try to do that.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> wrote in message
news:u38Puo$jGHA.4748[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
> Actually Redemption does not even try to move the message since doing so
> will result in a ghost message. And by default Outlook creates new
> messages
> in the Drafts folder.


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net