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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MehramAuthor Commented:
Reference is also added on top

Imports Outlook = Microsoft.Office.Interop.Outlook
Éric MoreauSenior .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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.