locked
Diplaying Email window on the foreground RRS feed

  • Question

  • User-809753952 posted

    I am using the following code to open outlook from VB.NET

    Dim body As String = "<html><a href=file:////\\\\server2\\inetpub\\wwwroot\\Tr\\Attachments\\" & LblTaskNo.Text & "\\" & phase & " target=blank>Link to files</a></html>"
                   Dim script As String = "" & _
    "    var outlookApp = new ActiveXObject(""Outlook.Application"");" & _
    "    var nameSpace = outlookApp.getNameSpace(""MAPI"");" & _
    "    var mailFolder = nameSpace.getDefaultFolder(6);" & _
    "    var mailItem = mailFolder.Items.add('IPM.Note.FormA');" & _
    "    mailItem.HTMLBody = '" & body & "';" & _
    "    mailItem.Subject = '" & LblTaskNo.Text & " - " & phase & " ';" & _
    "    mailItem.To ='abc@xyz.com' ;" & _
    "    mailItem.display(0);"
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Display Email", script, True)

    This works fine. But I need to popup the email window on the top of the screen. (I can see the outlook icon blinking on the taskbar.)

    Wednesday, April 2, 2014 4:58 AM

Answers

  • User-417640953 posted

    Hi mnmhemaj,

    Thank you post the issue to asp.net forum.

    Based on your code, I see you want to open the outlook window from the javascript.

    For this issue, I suggest you use the mailto to complete it like below.

       <script language="javascript">
    
               function TriggerOutlook() {
    
                   var body = escape(window.document.title + String.fromCharCode(13) + window.location.href);
    
                   var subject = "Take a look at this cool code snippet from CodeDigest.Com!!";
    
                   window.location.href = "mailto:?body=" + body + "&subject=" + subject;
    
               }
                
        </script>
    <input id="Button1" type="button" value="button" onclick="TriggerOutlook()" />

    You can also use the ActiveXObject("Outlook.Application") for it like below.

    http://blogs.msdn.com/b/rajnishkaushik/archive/2007/05/06/compose-and-send-e-mail-from-javascript-by-using-outlook-automation-2007.aspx

    Hope that helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 3, 2014 3:36 AM

All replies