Link to home
Start Free TrialLog in
Avatar of ITMikeK
ITMikeKFlag for United States of America

asked on

Open Outlook to compose and e-mail

I have a ASP.NET3.5 Web App with c# code.
When the user clicks a button that performs an Insert with a certian field "checked" I would like to automatically open Outlook 2007 (on the workstation) to compose an e-mail with the recipients and a default text already filled in for sending.
I have read about a couple of ways to do this....I am looking for more feedback as to what is the "best" way.
ASKER CERTIFIED SOLUTION
Avatar of deadlyDev
deadlyDev
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ITMikeK

ASKER

DeadlyDev,
How would I link this to a control....say a checkbox in a template field of a DetailsView?
I would suggest using JavaScript.... its a bit difficult exactly how without having a look at the html source of the page.... Can you provide a link, or attach the file, and I'll throw something together for you...
Avatar of ITMikeK

ASKER

DD,
The item I want this to work with is "Checkbox1" that binds "Status". It is a template field.
Thanks
<asp:BoundField DataField="TranDt" HeaderText="TranDt" 
                SortExpression="TranDt" Visible="False" />
            <asp:BoundField DataField="Weight" HeaderText="Weight" 
                SortExpression="Weight" />
            <asp:TemplateField HeaderText="Coil on hold" 
                SortExpression="Status">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Status") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Status") %>' />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="FinishedGood" SortExpression="FinishedGood">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("FinishedGood") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:CheckBox ID="CheckBox2" runat="server" 
                        Checked='<%# Bind("FinishedGood") %>' />
                </InsertItemTemplate>
                <ItemTemplate>

Open in new window

Avatar of ITMikeK

ASKER

I may have to do this in the code behind instead.......
Thats fine... I will have a look at this tomorrow morning for you... am a bit tired :P shouldn't take long :)
Avatar of ITMikeK

ASKER

This code worked for me....
var outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
            // Create mail message. 
            var newMail = (Microsoft.Office.Interop.Outlook.MailItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            newMail.To = "mike@rocksidetechnology.com";
            newMail.Subject = "Coil On Hold at Cleaning House";
            newMail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
            newMail.HTMLBody = "<p>Bernie and Brad,</p><p>There is a Coil that has been placed on hold at the Cleaning House Workstation.</p><p>The Coil number is - ";
            newMail.Display(false);

Open in new window

Avatar of ITMikeK

ASKER

This is a solution, but perfoming the task in C# was the way to go.
Glad to see you found a solution. Now that I see your full intention, you certainly have the best solution to the problem!