[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2133
  • Last Modified:

invoking outlook from aspx code behind page.

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
mani_sai
Asked:
mani_sai
  • 7
  • 5
  • 2
1 Solution
 
raterusCommented:
What error are you getting when you put too much info?  These things do help :-)
0
 
mani_saiAuthor Commented:
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
 
raterusCommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mani_saiAuthor Commented:
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
 
netjkusCommented:
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
 
netjkusCommented:
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
 
mani_saiAuthor Commented:
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
 
mani_saiAuthor Commented:
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
 
raterusCommented:
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
 
mani_saiAuthor Commented:
can anyone suggest how to invoke an client outlook from asp.net application?

thanks
Mani
0
 
raterusCommented:
I've answered his question, he just didn't like the answer and kept asking the question.
0
 
mani_saiAuthor Commented:
Hello Experts,

So far my problem is not solved.

Thanks
0
 
raterusCommented:
http://www.experts-exchange.com/help.jsp#hi54

I believe this applies in your situation.
0
 
mani_saiAuthor Commented:
Hello Jayakanthan,

I used SMTP classes as per your suggestion.

It  works great. Thanks a lot.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now