Sent Outlook draft from other Computer

2019-09-07 04:36发布

问题:

I got eMail account on Exchange Server and that situation. I start on my Computer outlook (connected to this Email) run this code. The Email will created and saved in drafts.Thats working fine.

Than i take my notebook (connected to the same account) and try to sent it from the drafts. Get error wrong email address but it looks like correct address "test@test.com". If i delete this and type one more time the same address from my keyboard "test@test.com" it works.I got Windows 7 ,`Outlook 2013 with disabled Cached Exchange Mode.

_OutlookApplication = New Microsoft.Office.Interop.Outlook.Application
Dim mailItem = CType(_OutlookApplication.CreateItem(OlItemType.olMailItem), MailItem)

mailItem.Recipients.Add("test@test.com")
mailItem.Body ="Text"
mailItem.Subject = "Subject"
mailItem.Save()

Why should i retype the address? and how can i fix it?

回答1:

_OutlookApplication = New Microsoft.Office.Interop.Outlook.Application
Dim mailItem = CType(_OutlookApplication.CreateItem(OlItemType.olMailItem), MailItem)
Dim _TestRec As Recipient

_TestRec=mailItem.Recipients.Add("test@test.com")
_TestRec.AddressEntry.Address = "test@test.com"

mailItem.Body ="Text"
mailItem.Subject = "Subject"
mailItem.Save()

The problem is - mailItem.to setting only the Display Name. Had only to create a Recipient and set Recipient.AddressEntry.Address mailItem.Recipients.Add("test@test.com")