C# Tutorials and offshore development in India

Tutorials Resources Forum Reviews Interview Jobs Projects Training Your Ad Here


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...




Forums » .NET » Visual Studio »

How to open Outlook Express Window in ASP.NET page?


Posted Date: 13 Sep 2007      Posted By: Vijay Kumar Naidu      Member Level: Gold     Points: 2   Responses: 3



Dear Software Engineers,

I would like to know how to open Outlook Express Mail Window with my e-mail address in "To" field? If I click a link, it should open the mail window of Outlook Express. I am not talking about mailing through ASP.NET page. I believe I am clear with the information.

No Hurries! Take you time.

Thanks in advance.

-Vijay Kumar





Responses

Author: sangeethapalani    13 Sep 2007Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

hi


Basically there are three ways of doing this.

Using “mailto” to open the outlook Application
Using the traditional SMTP Send Mail
Using the Outlook Object Library to open the outlook along with an added attachment as an integral part of the application.
Using Mailto Link
This is a cheesy way of doing it. Pass the attributes along with the mailto

<A href=”mailto:Bob@somewhere.com?Cc:Roxy@righthere.com&Subject:
Using Mailto to send mails&Body:this is a test”>.

However if you want to use this in a VB.Net LinkLabel. You can do it this way
Dim strURL as String strURL = “mailto:Bob@somewhere.com?Cc:Roxy@righthere.com&Subject:
Using Mailto to send mails&Body:this is a test” Process.Start(strURL)

Using SMTP Send Mail
Before you start coding make sure you import the related namespace
Imports System.Web.Mail
Here goes the code
Public Function SMTPCall()
Dim strTo As String
Dim strFrom As String
Dim strBody As String
Dim strSubject As String
strTo = "Bob@somewhere.com"
' Make sure you set the from address,
'some SMTP servers wouldn't send a mail without the FROM address
strFrom = "Roxy@righthere.com"
strBody = "Test on Sending Mail"
strSubject = "Did this mail reach you yet?"
SmtpMail.Send(strFrom, strTo, strSubject, strBody)
End Function

Looks good, but the limitation with the above two methods is you cannot send an attachment. What if the user wants to access the outlook address book and also send the mail an attachment?
Using MSOutlook Object Library
Here’s a small piece of code for outlook integration with VB.Net using MS Outlook object Library.
First instantiate the Outlook application object.
Make sure you add the references in the Project References.
Right click on the References in the Solution Explorer. Add “Microsoft Outlook 10.0 Object Library”.
Public Function OutlookCall()
'Take an instance of the Outlook App
Dim oOutlook As New Outlook.Application()
' Create an instance of the MailItem
Dim oMailitem As Outlook.MailItem
' Create an instance of the Attachment
Dim oAttach As Outlook.Attachment
oMailitem = oOutlook.CreateItem(Outlook.OlItemType.olMailItem)
oMailitem.To = “Bob@somewhere.com”
oMailitem.Cc = “Roxy@righthere.com”
oMailitem.Subject = "Email Integration with Outlook and VB.Net"
'txtFilepath is a text box that contains the path for attachment.
If (txtFilepath.Text = "") Then
MsgBox ("You did not attach a file")
Else
'Attach the file Path to the Mail Item
oMailitem.Attachments.Add(txtFilepath.Text)
End If
'PING….Displays the Outlook along with the To,Cc,Subject and Attachment
oMailitem.Display()
End Function

There are a lot of other features you can do with this outlook object. Hope this helps.

Note:
Microsoft Outlook should be the installed on the machine.
Microsoft Outlook is assumed as the default mail client application.
If an existing instance of outlook send item is already running, it would still create a new mail Message.

this vl help u

Regards
P.sangeetha



Author: Vijay Kumar Naidu    13 Sep 2007Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi Sangeetha,

Your solutions are absolutely great!! You cleared my doubt.

Thank you very much.

Regards,
Vijay Kumar.



Author: Vijay Kumar Naidu    13 Sep 2007Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi Sangeetha,

Your solutions are absolutely great!! You cleared my doubt.

Thank you very much.

Regards,
Vijay Kumar.



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Please help regarding interview
Previous : Regarding on Modules in C#,plzzzz help me,it's urgentttttttttttttt
Return to Discussion Forum
Post New Message
Category: Visual Studio

Related Messages




About Us    Contact Us    Privacy Policy    Terms Of Use