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 » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Programatically click the Send button.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 1st 10, 04:44 AM posted to microsoft.public.outlook.program_forms
Marketware
external usenet poster
 
Posts: 6
Default Programatically click the Send button.

I have a program that pastes the contents of a word document into an email
message. (See Below)

Now what I need to do is programatically click the Send button.

I realize there are easier ways to send an email, but I need to be able to
cut and paste exactily what is in the word document.

The question is, how to use either the inspector object or whatever to click
that send button.

mail = (Outlook.MailItem)oMailFolder.Items.Add(Outlook.Ol ItemType.olMailItem);

object start = WordApp.MergeDoc.Content.Start;
object end = WordApp.MergeDoc.Content.End;
Word.Range range = WordApp.MergeDoc.Range(ref start, ref end);

range.Copy(); //Put Contents into clipboard

inspector = mail.GetInspector;
if (inspector.EditorType == OlEditorType.olEditorWord)
{
Word.Document WordEditor = (Word.Document)inspector.WordEditor;
start = WordEditor.Content.Start;
end = WordEditor.Content.End;

Word.Range range2 = WordEditor.Range(ref start, ref end);

range2.Paste();

}

//Click Send Button

Thanks!!

bob




Ads
  #2  
Old June 1st 10, 12:55 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP][_4_]
external usenet poster
 
Posts: 552
Default Programatically click the Send button.

You already have the message as the mail object, so just call mail.Send
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54

"Marketware" wrote:

I have a program that pastes the contents of a word document into an email
message. (See Below)

Now what I need to do is programatically click the Send button.

I realize there are easier ways to send an email, but I need to be able to
cut and paste exactily what is in the word document.

The question is, how to use either the inspector object or whatever to click
that send button.

mail = (Outlook.MailItem)oMailFolder.Items.Add(Outlook.Ol ItemType.olMailItem);

object start = WordApp.MergeDoc.Content.Start;
object end = WordApp.MergeDoc.Content.End;
Word.Range range = WordApp.MergeDoc.Range(ref start, ref end);

range.Copy(); //Put Contents into clipboard

inspector = mail.GetInspector;
if (inspector.EditorType == OlEditorType.olEditorWord)
{
Word.Document WordEditor = (Word.Document)inspector.WordEditor;
start = WordEditor.Content.Start;
end = WordEditor.Content.End;

Word.Range range2 = WordEditor.Range(ref start, ref end);

range2.Paste();

}

//Click Send Button

Thanks!!

bob




  #3  
Old June 1st 10, 07:40 PM posted to microsoft.public.outlook.program_forms
Marketware[_2_]
external usenet poster
 
Posts: 3
Default Programatically click the Send button.

Sue,

You are right. But at first I was having a problem getting the contents of
the word document to go when I used mail.Send(). I added mail.Save(), and
everything works fine with one exception. It's putting the email in the
drafts folder, and doesn't leave the drafts until the automatic send/receive
occurs (every 5 Min. on my system).

Is this the best practice? Or should I try to force the Send/Receive? and
if So, can you direct me on forcing a Send/Receive?

Thanks again.

bob

Sue Mosher [MVP] wrote:
You already have the message as the mail object, so just call mail.Send
I have a program that pastes the contents of a word document into an email
message. (See Below)

[quoted text clipped - 33 lines]

bob


  #4  
Old June 1st 10, 08:20 PM posted to microsoft.public.outlook.program_forms
Marketware[_2_]
external usenet poster
 
Posts: 3
Default Programatically click the Send button.

I guess I spoke too soon. The emails looked great in the Drafts folder with
the body of the Word Document merged into the body of the email just fine.
But, when they returned (I sent them to myself) the body of the email was
empty. Have you ever seen this behavior before?

bob

Marketware wrote:
Sue,

You are right. But at first I was having a problem getting the contents of
the word document to go when I used mail.Send(). I added mail.Save(), and
everything works fine with one exception. It's putting the email in the
drafts folder, and doesn't leave the drafts until the automatic send/receive
occurs (every 5 Min. on my system).

Is this the best practice? Or should I try to force the Send/Receive? and
if So, can you direct me on forcing a Send/Receive?

Thanks again.

bob

You already have the message as the mail object, so just call mail.Send
I have a program that pastes the contents of a word document into an email
message. (See Below)

[quoted text clipped - 33 lines]

bob


  #5  
Old June 1st 10, 08:41 PM posted to microsoft.public.outlook.program_forms
Marketware[_2_]
external usenet poster
 
Posts: 3
Default Programatically click the Send button.

Another update. It appears as if it loses the body of the email going from
the Drafts folder to the Sent Items folder. Weird. I'd love a guess at
what's happening.

Sue Mosher [MVP] wrote:
You already have the message as the mail object, so just call mail.Send
I have a program that pastes the contents of a word document into an email
message. (See Below)

[quoted text clipped - 33 lines]

bob


  #6  
Old June 2nd 10, 12:58 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP][_4_]
external usenet poster
 
Posts: 552
Default Programatically click the Send button.

I haven't seen that behavior, but I would use a different approach to
transferring the content.

Since this forum is officially discontinued, I suggest we continue the
conversation in the Outlook Developers forum at
http://social.msdn.microsoft.com/For...ookdev/threads
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54



"Marketware" wrote:

I guess I spoke too soon. The emails looked great in the Drafts folder with
the body of the Word Document merged into the body of the email just fine.
But, when they returned (I sent them to myself) the body of the email was
empty. Have you ever seen this behavior before?

bob

Marketware wrote:
Sue,

You are right. But at first I was having a problem getting the contents of
the word document to go when I used mail.Send(). I added mail.Save(), and
everything works fine with one exception. It's putting the email in the
drafts folder, and doesn't leave the drafts until the automatic send/receive
occurs (every 5 Min. on my system).

Is this the best practice? Or should I try to force the Send/Receive? and
if So, can you direct me on forcing a Send/Receive?

Thanks again.

bob

You already have the message as the mail object, so just call mail.Send
I have a program that pastes the contents of a word document into an email
message. (See Below)
[quoted text clipped - 33 lines]

bob


.

 




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
Outlook : Run the VBA macro on send button click masani paresh[_2_] Outlook and VBA 10 February 10th 09 04:22 PM
Commandbar Button Click Handler saturn Add-ins for Outlook 1 August 7th 07 09:39 PM
An event raise twice when click the button. David Add-ins for Outlook 0 July 16th 06 12:25 PM
click a button on the toolbar (via VBA?) Dan Outlook and VBA 7 May 2nd 06 09:35 AM
click a button on the toolbar (via VBA?) Dan Outlook - General Queries 2 May 1st 06 01:39 PM


All times are GMT +1. The time now is 11:25 AM.


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