M
Mark Ham via OfficeKB.com
I have the following Visual Basic .Net code. I tried Redemption (yesterday) and still do not quite understand it. I want to create a mail item that looks like it came into the "Inbox" and was moved to a specific folder. I want to populate the mail item with data from a flat text file. I do not want it to look like a draft ready to be sent out. Here is my code:
' Create a new MailItem object
Dim newMail As Outlook.MailItem
' Assign values to the newMail MailItem
newMail = objFolder.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = "My test subject"
newMail.Body = "The test body of the email"
newMail.To = "xxx"
newmail.SenderEmailAddress = "yyy" <- this does not work!
' So I have to use this
newMail.SentOnBehalfOfName = "yyy"
newMail.Move(objFolder)
The problem is, it ends up on the new folder as a Draft with "On Behalf of yyy". I cannot set the "ReceivedTime", flag that it was Sent, or any of the fields to make it look like an "Inbox" email.
If anyone can help I will greatly appreciated it,
Thanks in advance,
Hammer
' Create a new MailItem object
Dim newMail As Outlook.MailItem
' Assign values to the newMail MailItem
newMail = objFolder.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = "My test subject"
newMail.Body = "The test body of the email"
newMail.To = "xxx"
newmail.SenderEmailAddress = "yyy" <- this does not work!
' So I have to use this
newMail.SentOnBehalfOfName = "yyy"
newMail.Move(objFolder)
The problem is, it ends up on the new folder as a Draft with "On Behalf of yyy". I cannot set the "ReceivedTime", flag that it was Sent, or any of the fields to make it look like an "Inbox" email.
If anyone can help I will greatly appreciated it,
Thanks in advance,
Hammer