A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Exception thrown on MailItem.Send



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 5th 07, 03:49 PM posted to microsoft.public.outlook.program_addins
bstrum
external usenet poster
 
Posts: 19
Default Exception thrown on MailItem.Send

The ResolveAll call is returning false on this one machine so the email does
not go out. Why would this happen? How can I get around this? I am sure
that the email address specified is valid and even if it is not, so what?

Lastly, is there a way to duplicate this in a test environment? Getting a
fix for this is really slow because it only happens on this one machine at a
client site.

Thank you,

-Ben

"Sue Mosher [MVP-Outlook]" wrote:

Try calling Recipients.ResolveAll and perform the send only if it returns True.

--
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/article.aspx?id=54

"bstrum" wrote in message ...
I am getting an exception thrown with our c# outlook addon installed on one
machine running Office 2003. The exception is thrown when I try to call Send
on a mail item that I have programatically created. The code looks like this:

Note: This code uses late binding.

// -- in the Item_Send event --
MSOutlook.MailItem mi; // assume initialized from the Item_Send argument

// create the new mail item that will be programatically sent
object otmp = mi.Application.CreateItem(MSOutlook.OlItemType.olM ailItem);
MSOutlook.MailItem m = (MSOutlook.MailItem)MO.COMWrapper.Wrap(
otmp,
typeof(MSOutlook.MailItem));
m.BodyFormat = MSOutlook.OlBodyFormat.olFormatHTML;
m.To = mi.To;
m.Subject = "Some subject";
m.Body = "Test Body";
m.Save();
m.Send(); // throws exception on one client computer

The actual exception thrown is
"Exception has been thrown by the target of an invocation."

I have tried everything I can to duplicate the exception in our test
environment to no avail. Any ideas why something as simple as this would
throw an exception?

Thank you,

Ben Strum
ThinkTron Corporation


  #2  
Old June 5th 07, 04:54 PM posted to microsoft.public.outlook.program_addins
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Exception thrown on MailItem.Send

This is not an appropriate way to copy recipients:

m.To = mi.To;

There is no guarantee that the display names, which is what To shows, will resolve to valid addresses. Instead, you need to iterate the mi.Recipients collection and use m.Recipients.Add to create a new Recipient based on the information from the original item.

To test, use one or more recipients whose display names are radically different from their actual email addresses.
--
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/article.aspx?id=54

"bstrum" wrote in message ...
The ResolveAll call is returning false on this one machine so the email does
not go out. Why would this happen? How can I get around this? I am sure
that the email address specified is valid and even if it is not, so what?


Lastly, is there a way to duplicate this in a test environment? Getting a
fix for this is really slow because it only happens on this one machine at a
client site.

Thank you,

-Ben

"Sue Mosher [MVP-Outlook]" wrote:

Try calling Recipients.ResolveAll and perform the send only if it returns True.



"bstrum" wrote in message ...
I am getting an exception thrown with our c# outlook addon installed on one
machine running Office 2003. The exception is thrown when I try to call Send
on a mail item that I have programatically created. The code looks like this:

Note: This code uses late binding.

// -- in the Item_Send event --
MSOutlook.MailItem mi; // assume initialized from the Item_Send argument

// create the new mail item that will be programatically sent
object otmp = mi.Application.CreateItem(MSOutlook.OlItemType.olM ailItem);
MSOutlook.MailItem m = (MSOutlook.MailItem)MO.COMWrapper.Wrap(
otmp,
typeof(MSOutlook.MailItem));
m.BodyFormat = MSOutlook.OlBodyFormat.olFormatHTML;
m.To = mi.To;
m.Subject = "Some subject";
m.Body = "Test Body";
m.Save();
m.Send(); // throws exception on one client computer

The actual exception thrown is
"Exception has been thrown by the target of an invocation."

I have tried everything I can to duplicate the exception in our test
environment to no avail. Any ideas why something as simple as this would
throw an exception?

Thank you,

Ben Strum
ThinkTron Corporation


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automate Spell Check on MailItem.Send() ??? Brian McCullough Add-ins for Outlook 1 March 30th 07 03:18 PM
exception Reda Outlook - Calandaring 0 March 1st 07 08:26 PM
Mailitem.Save() function throws an exception for POP3 messages Nithin Outlook - General Queries 3 September 4th 06 03:35 PM
How can I create a MailItem that displays like a received MailItem ? Clive Outlook - Using Forms 0 February 27th 06 05:14 PM
Losing handle to MailItem when send donald Add-ins for Outlook 8 February 1st 06 07:09 PM


All times are GMT +1. The time now is 01:00 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.