Outlook Email not generating on published application (local network)

Dear Experts,
I have a link button to send daily report in my asp.net application on click. The code is working perfectly in my system (where code is available). However, after publishing the same code is not working my code and result of out look is attached. Please help
Protected Sub lnkDailyReport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkDailyReport.Click
        Dim objApp As Outlook.Application = New Outlook.Application()
        Dim mail As Outlook.MailItem = Nothing
        mail = DirectCast(objApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)

        Dim target As String = "rpt_DailyReport.aspx?CompanyId=" & Session("CompanyId")

        'Render the page  
        Dim htmlStringWriter As New System.IO.StringWriter()
        Server.Execute(target, htmlStringWriter)

        mail.[To] = ""
        mail.Subject = "Daily Report" & DateTime.Now
        mail.CC = ""
        mail.HTMLBody = htmlStringWriter.ToString()
    End Sub

Open in new window

Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Surely because Outlook is not properly configured on the server (which won't be a good idea anyway). The Click event runs on the server.

Better use other mechanism such as System.Net.Mail: http://emoreau.com/Entries/Articles/2007/09/Using-SystemNetMail.aspx and http://emoreau.com/Entries/Articles/2010/07/Sending-e-mails-with-attachments-a-different-method.aspx
MehramAuthor Commented:
Reference is also added on top

Imports Outlook = Microsoft.Office.Interop.Outlook
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.