Programatically click the Send button.

Status
Not open for further replies.
M

Marketware

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.OlItemType.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
 
S

Sue Mosher [MVP]

You already have the message as the mail object, so just call mail.Send

Sue Mosher

"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.OlItemType.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

>
 
M

Marketware

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
 
M

Marketware

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
 
M

Marketware

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
 
S

Sue Mosher [MVP]

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/Forums/office/en-US/home?forum=outlookdev

Sue Mosher

"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


> .
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Is it possible to set a message as sent programatically? Outlook VBA and Custom Forms 1
D Is it possible to set a message as sent programatically? Outlook VBA and Custom Forms 1
S How to insert a picture programatically Outlook VBA and Custom Forms 12
E DASL Filter doesn't work when defined programatically Outlook VBA and Custom Forms 1
H Run .dll programatically Outlook VBA and Custom Forms 7
R copying a custom view from a public folder and distributing programatically Outlook VBA and Custom Forms 3
K Access to mailbox programatically Outlook VBA and Custom Forms 1
K Access to mailbox programatically Outlook VBA and Custom Forms 1
F Jump to Inbox folder when click on Favorite Using Outlook 8
M White square in body of Outlook Messages (O2016 Version 2012 32bit Click To Run) Using Outlook 4
Eike Move mails via macro triggered by the click of a button? Outlook VBA and Custom Forms 0
P Unread Until Click Another Message? Using Outlook 2
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
Diane Poremsky Using Scanpst in Outlook Click to Run Using Outlook 0
J Can Click to Drag Custom Form Field But Cannot Drop When Designing in Outlook 2007 Outlook VBA and Custom Forms 2
B Open a folder / subfolder of a PST in single click Outlook VBA and Custom Forms 4
C Reminder for single-click appointment Using Outlook 2
Diane Poremsky Contacts are missing when you click the To button Using Outlook 0
M Office 365 Click to run BCM (Business Contact Manager) 0
williamlambton Reinstate "Open" button on mail item right-click context menu. Outlook Wishlist 2
B Auto name checking upon Tab or Click off To field(s) Using Outlook 19
F Jump to Inbox folder when click on Favorite Using Outlook 0
D Must now "View on Facebook" for Mentions/Comments-Outlook 2013 click-to-run Using Outlook 2
I BCM Opportunity: click on "new op" opens a "new tasks" BCM (Business Contact Manager) 0
M Automatically move Outlook message to the specific folder when click on reply to all Using Outlook 4
M Blank Pop-up Window when click "Manage Sharing" BCM (Business Contact Manager) 1
Emerogork How do I remove "Delete Folder" from the right-click menu? Using Outlook 1
R click to toggle quick click category reasigns to where ? Using Outlook 2
L Add to Right Click Menu Using Outlook 10
T Is the standalone Outlook 2013 click-to-run or msi? Using Outlook 1
A Uninstall Click and Run Exchange Server Administration 2
B Right click-drag no longer creates hyperlinks Using Outlook 2
A email folders appear empty, at first click Using Outlook 2
S How to add a new menu item to a right click context menu of a link Using Outlook 5
P "open" command in right click context menu Outlook Wishlist 4
L Outlook 2010 Instant Search Pops When I Click Using Outlook 6
M When I click “new message” in outlook, my cursor defaults to the body of the m Using Outlook 6
B right click outlook objects in OL2010 acts on current inbox mailitem Using Outlook 6
T Click "A" to see all email from people with names starting with A... etc Using Outlook 3
V Can't click on embedded link in Outlook e-mails--error message "not allowed" Using Outlook 6
M right click contact to create an appointment Using Outlook 4
T drag drop/opening drop down/single click acts like double/highlighting Using Outlook 7
F When I click on link in email nothing occurs Using Outlook 7
K call a help file when click on a button xml ribbon Outlook VBA and Custom Forms 1
M auto click hyperlink?! Outlook VBA and Custom Forms 1
M Auto click a hyperlink Outlook VBA and Custom Forms 2
A click on contact behaviour Outlook Wishlist 2
H Program "Click on Ribbon Button" Using VBA Outlook VBA and Custom Forms 1
J Macro to open email (like double click) in Outlook Outlook VBA and Custom Forms 4
M How to provide custom functionality on click of "New"? Outlook VBA and Custom Forms 1

Similar threads

Top