Last post Feb 07, 2017 05:16 PM by pvong
Feb 07, 2017 04:41 PM|pvong|LINK
I've tried multiple things and I just don't get it. The user will always have Outlook 2010 on his desktop on. All I want to do is for the user to click a linkbutton and then it creates a NEW email with a To from a textbox and Subject from another textbox.
I've created a test page and here's all I've tried.
- I've added a reference to the Microsoft Outlook 10.0 Object Library in VStudio COM
- I read it's best to install Office onto the IIS server, so I did that also.
- I have Imports Microsoft.Office.Interop.Outlook in my code behind.
The page has two simple boxes and one linkbutton
I've searched the internet and I've tried multiple things and nothing will just create a new email in outlook and just stick the To and Subject in for me. This was the closest I got to without getting error messages. When I click on the LB, the browser
just spins like it's trying to do something but nothing ever happens.
Partial Class DeleteMail
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs) Handles LinkButton1.Click
Dim oApp As New Microsoft.Office.Interop.Outlook.Application()
Dim oMsg As MailItem
oMsg = oApp.CreateItem(oApp.olMailItem)
oMsg.To = ToBox.Text
oMsg.Subject = SubjectBox.Text
Please help a newbie. Thanks in advance.
Feb 07, 2017 04:47 PM|mgebhard|LINK
Use a link where the href is set to mailto. This will open the client's default email application.
Your code is running on a web server not the client's machine.
Feb 07, 2017 04:57 PM|kaushalparik27|LINK
you can make use of mailto
<a href="mailto:email@example.com?subject=free chocolate">Send Email</a>
Here are some example:
hope that helps./.
Feb 07, 2017 05:16 PM|pvong|LINK
Thank you, this was much easier than I thought!!!