Solved

invoking outlook from aspx code behind page.

Posted on 2004-09-20
16
2,116 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
ID: 12106200
What error are you getting when you put too much info?  These things do help :-)
0
 
LVL 8

Author Comment

by:mani_sai
ID: 12106261
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
ID: 12106401
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 8

Author Comment

by:mani_sai
ID: 12106779
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
ID: 12115649
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
ID: 12115659
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
ID: 12117789
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
 
LVL 8

Author Comment

by:mani_sai
ID: 12143075
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
ID: 12143153
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
ID: 12144278
can anyone suggest how to invoke an client outlook from asp.net application?

thanks
Mani
0
 
LVL 33

Expert Comment

by:raterus
ID: 12369079
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
ID: 12369179
Hello Experts,

So far my problem is not solved.

Thanks
0
 
LVL 33

Expert Comment

by:raterus
ID: 12369303
http://www.experts-exchange.com/help.jsp#hi54

I believe this applies in your situation.
0
 
LVL 8

Author Comment

by:mani_sai
ID: 12370146
Hello Jayakanthan,

I used SMTP classes as per your suggestion.

It  works great. Thanks a lot.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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