Received date empty

M

Marc

Created an Outlook mail item programmatically
and sent it by using Redemption safemailitem.
Next I created a new folder in Personal Folders
and dragged and dropped that sent mail item in to that
new folder from Sent Items folder.
Then I checked the Received date value of the mail,
that is empty. This is my VFP code to send mails.
Pls someone help..

poOutlook = CREATEOBJECT("Outlook.Application")
loOutBox = poOutlook.GetNameSpace("MAPI").GetDefaultFolder(4)
loRedemption = CREATEOBJECT("Redemption.SafeMailItem")
loOutBox = poOutlook.GetNameSpace("MAPI").GetDefaultFolder(4)
loRedemption.Item = toOutBox.Items.Add(0)
loEmailItem = loRedemption
loEmailItem.To = "(e-mail address removed)"
loEmailItem.Subject = "Test received date "+TTOC(DATETIME())
loEmailItem.BodyFormat = 1
loEmailItem.Body = "Test received date"
loOutBoxMailItem = loEmailItem.Move(loOutBox)
loMailItem = CREATEOBJECT("Redemption.SafeMailItem")
loMailItem.Item = loOutBoxMailItem
loMailItem.Send()
 
K

Ken Slovak - [MVP - Outlook]

I fail to understand the logic of what you're doing.

You are creating an email item in the Outbox, which is usually something not
done, assigning it to a SafeMailItem, moving the SafeMailItem to the same
folder it's already in as a different SafeMailItem, creating yet another
SafeMailItem, assigning that from the superfluous SafeMailItem you just
created, and then sending that final item.

Is there a reason for all this pretzel logic?

Why not just follow the KISS principle:

poOutlook = CREATEOBJECT("Outlook.Application")

loMail = poOutlook.CreateItem(0)
loMail.To = "(e-mail address removed)"
loMail.Subject = "Test received date "+TTOC(DATETIME())
loMail.BodyFormat = 1
loMail.Body = "Test received date"

loRedemption = CREATEOBJECT("Redemption.SafeMailItem")
loRedemption.Item = loMail
loRedemption.Send()
 
M

Marc

Thanks Ken,
According to your code the mail store in Drafts
folder until it send. But I want to move that mail item
in to my Outbox and send.
 
K

Ken Slovak - [MVP - Outlook]

That's just cosmetic, but if that's what you want just add a line to move
the item to Outbox before calling Send on that referenced moved item.
 
G

Gianluca Vannozzi

Ken Slovak - said:
That's just cosmetic, but if that's what you want just add a line to move
the item to Outbox before calling Send on that referenced moved item.

Hi, can i ask you to post just few lines to move it to SentItems ?
Thank you very much.
 
D

Dmitry Streblechenko

Replace the line

loRedemption.Item = toOutBox.Items.Add(0)

with

loOutlookItem = poOutlook.CreateItem(0)
loOutlookItem = loOutlookItem .Move(loOutBox )
loRedemption.Item = loOutlookItem

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

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