Toxter

Hello everyone,

I'm developing an addin for Outlook 2003. I need to send an email (when user clicks

on my button in toolbar, while creating new message).

I've found MailItem.Send() method. Will that do the trick Will it

send it immediately or will it just move to Outbox folder (and wait for user to

click on Send/Receive)

Is there a way to invoke Send/Receive

Thanks.



Re: Visual Studio Tools for Office Outlook - How to send the mail Immediately ?

Sue Mosher - Outlook MVP

Calling Send puts the item in the Outbox. When the item is delivered to the outgoing mail server depends on Outlook's settings.

You can invoke Send/Receive through SyncObject.Start.





Re: Visual Studio Tools for Office Outlook - How to send the mail Immediately ?

Toxter

Hi, thanks for your reply.

I've found out that application session propery contains collections of SyncObjects.

In order to make sure that email is sent, I would like to invoke Send/Receive on 'All Accounts' SyncObject.

Here is the code snippet how I managed to obtain 'All Accounts' SyncObject (C++):

_NameSpacePtr ns;

HRESULT hr = applicationPtr->get_Session(&ns);

if(SUCCEEDED(hr)){

SyncObjectsPtr syncs;

hr = ns->get_SyncObjects(&syncs);

if(SUCCEEDED(hr)){

_bstr_t allAccounts = "All Accounts";

_SyncObjectPtr s;

hr = syncs->Item(CComVariant(allAccounts.GetBSTR()), &s);

if(SUCCEEDED(hr) && s){

_bstr_t name;

s->get_Name(&name.GetBSTR());

}

}

}

Is there a any other solution on how to obtain 'All Accounts' SyncObject (because user can rename 'All Accounts' group in Outlook)

Or maybe, better question would be: How can I obtain SyncObject of MailItem

Thanks.





Re: Visual Studio Tools for Office Outlook - How to send the mail Immediately ?

Sue Mosher - Outlook MVP

If you looked at the MailItem object in the object browser, you'd see it has no SyncObject. That wouldn't make sense.

If you're worried about the user renaming All Accounts, which is rare, then call Start on all members of the SyncObjects collection.





Re: Visual Studio Tools for Office Outlook - How to send the mail Immediately ?

Toxter

>If you looked at the MailItem object in the object browser, you'd see it has no SyncObject.

Yes I did looked indeed.

>
That wouldn't make sense.

I'm not sure why Could you elaborate on this

>
If you're worried about the user renaming All Accounts, which is rare, then call Start on all members of the SyncObjects collection.

Hmm, if that is the only solution...

Thanks for your help.




Re: Visual Studio Tools for Office Outlook - How to send the mail Immediately ?

Sue Mosher - Outlook MVP

There is no one-to-one relationship between an individual message and a send/receive group.



Re: Visual Studio Tools for Office Outlook - How to send the mail Immediately ?

Toxter

OK.
Thank you for your help.