How to call MailConsoleDemo to create new mail message

Thank you for your MailConsoleDemo.

I have put this into a class, exactly as described in your demo (I'm using the VB version and Visual Studio 2005):

http://www.aspose.com/wiki/default.aspx/Aspose.Network/MailSend.html

My problem is probably very simple: I do not know how to call the Shared Sub Main code from a button on a web form.

I have tried something like:

Protected Sub btnSendEmail_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSendEmail.Click

Dim test As New MailMessageConsoleDemo.MailConsoleDemo

test.Main()

End Sub

Unfortunately I do not understand what should go in the args.

I know this may seem like a very basic question, but any assistance would be gratefully appreciated.

With thanks

Simon

Hi Simon,

The sample provided on the wiki can run as it is as a console application. To use it in your web application, you need to do the following:

  1. Add ASP.Net folder to your website (App_Code) and put the sample class file in this folder.
  2. Make the class public so that it can be used in your project

    Public Class MailConsoleDemo

  3. Remove _ line and delete the Main() method arguments. The definition should be like

    Shared Sub Main()

  4. Now you can call this Main() method in your web form using the code below
    MailConsoleDemo.Main()
    Since its a shared/static method, you dont need to declare the class for it.

Please let me know if it works.

Hello Simon,

Please view the sample web demo. It might prove useful for you. I have made the method public and removed the shared keyword which is a better approach in this scenario.

saqib.razzaq:

Hello Simon,

Please view the sample web demo. It might prove useful for you. I have made the method public and removed the shared keyword which is a better approach in this scenario.

Saqib

Thank you for your prompt reply.

I have not yet tried your suggestion. I will do this later when I get home.

In the mean time, I cannot locate the attachment you have suggested I look at. It says "Attachment: Present (unavailable).

Please could you either resubmit via this forum, or directly to me at simonrichards_999@hotmail.com

With thanks

Simon Richards

Saquib

My appologies, but I have now located the zip file.

I will look at this later on and let you know if everything works successfully.

Thank you for your assistance.

Regards

Simon Richards

saqib.razzaq:

Hello Simon,

Please view the sample web demo. It might prove useful for you. I have made the method public and removed the shared keyword which is a better approach in this scenario.

Saqib

Thank you very much for the zip file attachment containing the sample code. This appears to have worked perfectly in that the code has now created an eml message in the \inetpub\mailroot\mailbox\hotmail.com\ folder on my SMTP server.

I've just got to work out how to send this message from a Hotmail account now!

With thanks

Simon