Solved

invoking outlook from aspx code behind page.

Posted on 2004-09-20
16
2,112 Views
Last Modified: 2012-06-21
Hello

This is the code i am using in my code behind page(asp.net).

Basically i am getting emailid's from sql database and populating in outlook(to, cc, bcc) and opening outlook for user to type body message and send mail after that.

I am using mailto to open the default outlook client.

The problem is if the email address length is more certain length i get an error.

How to pass unlimited string length to outlook from my aspx code behind page?


please help me out.

-----------------------------------------------------------------------------------------------------------------
 Private Sub SendAttach(ByVal drEmailGroups As SqlDataReader)


        Dim strEmailAddress


        If chkWorkEmail.Checked = True And chkHomeEmail.Checked = True Then

            While drEmailGroups.Read
                If drEmailGroups("WorkEmail") <> "" Then
                    If strEmailAddress = "" Then
                        strEmailAddress = drEmailGroups("WorkEmail")
                    Else
                        strEmailAddress = strEmailAddress + ";" + drEmailGroups("WorkEmail")
                    End If

                End If

                If drEmailGroups("HomeEmail") <> "" Then

                    If strEmailAddress = "" Then
                        strEmailAddress = drEmailGroups("HomeEmail")
                    Else
                        strEmailAddress = strEmailAddress + ";" + drEmailGroups("HomeEmail")
                    End If

                End If
            End While

        ElseIf chkWorkEmail.Checked = False And chkHomeEmail.Checked = False Then

            While drEmailGroups.Read
                If drEmailGroups("WorkEmail") <> "" Then

                    If strEmailAddress = "" Then
                        strEmailAddress = drEmailGroups("WorkEmail")
                    Else
                        strEmailAddress = strEmailAddress + ";" + drEmailGroups("WorkEmail")
                    End If

                End If
                If drEmailGroups("HomeEmail") <> "" Then

                    If strEmailAddress = "" Then
                        strEmailAddress = drEmailGroups("HomeEmail")
                    Else
                        strEmailAddress = strEmailAddress + ";" + drEmailGroups("HomeEmail")
                    End If

                End If

            End While

        ElseIf chkWorkEmail.Checked = True And chkHomeEmail.Checked = False Then
            While drEmailGroups.Read
                If drEmailGroups("WorkEmail") <> "" Then

                    If strEmailAddress = "" Then
                        strEmailAddress = drEmailGroups("WorkEmail")
                    Else
                        strEmailAddress = strEmailAddress + ";" + drEmailGroups("WorkEmail")
                    End If

                End If
            End While

        ElseIf chkWorkEmail.Checked = False And chkHomeEmail.Checked = True Then

            While drEmailGroups.Read
                If drEmailGroups("HomeEmail") <> "" Then

                    If strEmailAddress = "" Then
                        strEmailAddress = drEmailGroups("HomeEmail")
                    Else
                        strEmailAddress = strEmailAddress + ";" + drEmailGroups("HomeEmail")
                    End If

                End If
            End While

        End If

        If strEmailAddress <> "" Then

            If ddlEmailTo.SelectedValue = "TO" Then

                strEmailAddress = "mailto:" & strEmailAddress

            ElseIf ddlEmailTo.SelectedValue = "CC" Then
                strEmailAddress = "mailto:&cc=" & strEmailAddress

            ElseIf ddlEmailTo.SelectedValue = "BCC" Then
                strEmailAddress = "mailto:&bcc=" & strEmailAddress

            End If


            Response.Redirect(strEmailAddress)

        End If


    End Sub

-----------------------------------------------------------------------------------------------------------------

Thanks
Mani

0
Comment
Question by:mani_sai
  • 7
  • 5
  • 2
16 Comments
 
LVL 33

Expert Comment

by:raterus
Comment Utility
What error are you getting when you put too much info?  These things do help :-)
0
 
LVL 8

Author Comment

by:mani_sai
Comment Utility
When i hit response.redirect with the larger emailaddress string, i am getting the following page.

----------------------------------------------------------------------------------------------------------------------------
The page cannot be displayed
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

--------------------------------------------------------------------------------

Please try the following:

Click the  Refresh button, or try again later.

If you typed the page address in the Address bar, make sure that it is spelled correctly.

To check your connection settings, click the Tools menu, and then click Internet Options. On the Connections tab, click Settings. The settings should match those provided by your local area network (LAN) administrator or Internet service provider (ISP).
If your Network Administrator has enabled it, Microsoft Windows can examine your network and automatically discover network connection settings.
If you would like Windows to try and discover them,
click  Detect Network Settings
Some sites require 128-bit connection security. Click the Help menu and then click About Internet Explorer to determine what strength security you have installed.
If you are trying to reach a secure site, make sure your Security settings can support it. Click the Tools menu, and then click Internet Options. On the Advanced tab, scroll to the Security section and check settings for SSL 2.0, SSL 3.0, TLS 1.0, PCT 1.0.
Click the  Back button to try another link.



Cannot find server or DNS Error
Internet Explorer  

-------------------------------------------------------------------------------------------

Smaller emailaddresstring works fine with this code.

Is there any alternative solution to handle this situation.

Thanks
Mani

0
 
LVL 33

Expert Comment

by:raterus
Comment Utility
hmm, I think you are probably maxing out the address bar size limit the browser imposes.  I think IE has a limit of 4096 characters for the entire text you will see in the address bar.  You even coming close to that?  (Other browser have lower limits, but you should be able to get at least 1000).

As for ways around this, there aren't any I know of, can you possibly consolidate email addresses into group names?

--Michael
0
 
LVL 8

Author Comment

by:mani_sai
Comment Utility
do any one know how to solve this issue.

Basically i need to get the email address from sql database and open those email address in outlook.
User will go and type the message body and send the email manually.

I am using asp.net to develop the application.

I almost got it working using mailto function.
But i have browser max length violation using response.redirect.

can anyone help me out ?

you can see my code in the above mail.


Thanks
Mani
0
 
LVL 2

Accepted Solution

by:
netjkus earned 250 total points
Comment Utility
Maximum URL Length Is 2,083 Characters in Internet Explorer.  If you are using the GET method, you are limited to a maximum of 2,048 characters . POST, however, is not limited by the size of the URL for submitting name/value pairs, because they are transferred in the header and not the URL. Having said that, you may have to re-consider doing the Email stuff using Mailto method. Instead, use the SMTP Classes in .Net to implement this. So that you could use the POST to send the parameters. Also, you can allow the user to attach files, type the subject matter & a submit/Send button to send it at once.

I can provide many examples from the google search, if you need

-Jayakanthan
0
 
LVL 2

Expert Comment

by:netjkus
Comment Utility
The only difference is, it will not use the Outlook Client, instead you will have to create a web page that simulates all Outlook features that you may want..
0
 
LVL 8

Author Comment

by:mani_sai
Comment Utility
thanks for your reply.

I need to use Outlook mandatory, this is the user requirement.

Is there is anyway we can you post instead of get with mailto.

please let me know.

also since it is an asp.net web application , user should be able to invoke client outlook from there client machines.
and emailaddresss from SQL Db automatically pops up in the To, CC, BCC fields.

please suggest me with good solution.

thanks
Mani
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 8

Author Comment

by:mani_sai
Comment Utility
Hello,

I am trying to invoke default outlook client through my asp.net application.

I am getting the error on the line 266 mentioned below:

Server Error in '/EmailTestApps' Application.
--------------------------------------------------------------------------------

An attempt was made to reference a token that does not exist
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: An attempt was made to reference a token that does not exist

Source Error:


Line 264:                'System.Diagnostics.Process.Start("mailto:" & strEmailAddress)
Line 265:
Line 266:                System.Diagnostics.Process.Start("mailto:somebody@somedomain.com")
Line 267:

 what is the problem?
Can anyone help me out.

Thanks
Mani
0
 
LVL 33

Expert Comment

by:raterus
Comment Utility
You can't do that, even if you did work (which it won't) you would open the send email dialog on the Server!
0
 
LVL 8

Author Comment

by:mani_sai
Comment Utility
can anyone suggest how to invoke an client outlook from asp.net application?

thanks
Mani
0
 
LVL 33

Expert Comment

by:raterus
Comment Utility
I've answered his question, he just didn't like the answer and kept asking the question.
0
 
LVL 8

Author Comment

by:mani_sai
Comment Utility
Hello Experts,

So far my problem is not solved.

Thanks
0
 
LVL 33

Expert Comment

by:raterus
Comment Utility
http://www.experts-exchange.com/help.jsp#hi54

I believe this applies in your situation.
0
 
LVL 8

Author Comment

by:mani_sai
Comment Utility
Hello Jayakanthan,

I used SMTP classes as per your suggestion.

It  works great. Thanks a lot.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now