Outlook.Application oApp = new Outlook.Application();
Outlook._NameSpace oNameSpace = oApp.GetNamespace("MAPI");
Outlook.MAPIFolder oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);
oNameSpace.Logon(null, null, false, false);
Outlook._MailItem oMailItem =
(Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMailItem.To = "edwin....@navy.mil";
oMailItem.Subject = cboSubject.Text;
oMailItem.Body = txtMessage.Text;
oMailItem.Send();
In the application I am developing, the email DOES get sent through Outlook
2003, after the user approves the mail on the security dialog box. In 2007,
however, the Send() function results in the error:
Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
In the Outlook 2007 Trust Center, the Programmatic Access security setting
is set to "Warn me about suspicious activity when my antivirus software is
inactive or out of date (recommended)", which, although I cannot change it in
the Outlook interface, seems to me to be the appropriate level of security.
I really don't care if the security dialog box appears or not. It does
appear in Outlook 2003, and the user can approve the message. That's fine.
What I don't understand is why Office 2007 refuses to either send the email,
or provide a security dialog box for the user to approve it. I can save the
email. I can move it into the Outbox, or anywhere else. I can display the
email, and have the user manually click the send button. But I can't
actually send the email.
Since the rest of the organization is scheduled to upgrade to Office 2007 in
the near future, this is a matter of some pressing interest for me.
Any suggestions?
Have you tried adding a Namespace.Logon statement? That may be necessary if
Outlook isn't already running.
I've also seen people report good results from displaying the message before
adding recipients and sending.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
"Dale Franks" <Dale Fra...@discussions.microsoft.com> wrote in message
news:967D84CD-1BDD-4E03...@microsoft.com...
Although after the message displays, I can hit the send button on the
displayed message form, which sends the message promptly. It just won't send
programmatically.
The code already has the Namespace.Logon() command incorporated.
"Sue Mosher [MVP]" wrote:
> .
>
The only other thing I can think to try is calling Recipients.ResolveAll
before sending.
BTW, is there a particular reason why you're using Outlook and not
System.Net.Mail?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
"Dale Franks" <DaleF...@discussions.microsoft.com> wrote in message
news:144C99AC-68E5-47C3...@microsoft.com...
> My anti-virus software is up to date, according to the trust center. I
> did
> add the line to display the message prior to adding the recipient
> addresses
> and body text. It did display, and was correctly contstructed. The
> Send()
> function still resulkted in the same error. I can do everything
> imaginable
> to the message...except send it.
>
> Although after the message displays, I can hit the send button on the
> displayed message form, which sends the message promptly. It just won't
> send
> programmatically.
>
> The code already has the Namespace.Logon() command incorporated.
>
> "Sue Mosher [MVP]" wrote:
>
>> What does Tools | Trust Center tell you about the status of your
>> anti-virus
>> application?
>>
>> Have you tried adding a Namespace.Logon statement? That may be necessary
>> if
>> Outlook isn't already running.
>>
>> I've also seen people report good results from displaying the message
>> before
>> adding recipients and sending.
>>
Yeah. As I mentioned, I'm working in the US Navy NMCI environment. I'm not
allowed to touch an SMTP server. And, even if I could, the SMTP ports are
blocked anyway.
"Sue Mosher [MVP]" wrote:
> .
>
I have the same problem. If have resolved please suggest your solution that
fixed your problem.
My problem:
When I send the Email programmatically (C#) through Outlook 2007, it throws
Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
error and did not send the mail.
As when OUTLOOK 2007 process is started in the background, the same
application sends successfully the email.
The same application sends the email on another machine where OutLook 2003
is installed, without the outlook 2003 process started in the background.
I appreciate your solution.
Thanks,
SAM
I found a soultion for my problem.
For Outlook 2007, the code needs Outlook.Inpector object.
Outlook.Application oApp = null;
Outlook.MailItem oMsg = null;
Outlook.Inspector oAddSig = null;
oApp = new Outlook.Application();
oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oAddSig = oMsg.GetInspector;
After adding Inspector object the code sends email through Outlook 2007.
That is the solution to my problem.
With Outlook 2003, the code does not need this Inspector object. Without the
Inspector object, the Outlook 2003 sends email.
THX
SAM
I have a similar problem with my VB5 program using MAPI trying to send Email
thru Outlook 2000. I have an unanswered post below but wondered if you could
help.
I have a VB5 pgm that uses MAPI to send emails to customers. Everything
works fine when "Outlook Express" is installed on my XP computer. When I
replaced Outlook Express with "Outlook 2002", it appears that my pgm sends
emails out just fine, but when I click Outlook I get an error message "System
Administrator: None of your e-mail accounts could send to this recipient."
What is wrong and how can I fix this?
Dennis Rose