Sending emails

MiServer is Dyalog's APL-based web development framework

Sending emails

Postby Gantois on Fri Oct 24, 2014 12:35 pm

Hello Brian, Good morning !

Could you give me a help about send emails ? Where can I read and/or get an example about it? I already have a contact form (mild server page). After I will send messages from within a client file.

Thanks,
Marco Gantois
Gantois
 
Posts: 89
Joined: Thu Apr 17, 2014 9:44 am

Re: Sending emails

Postby Vince|Dyalog on Mon Oct 27, 2014 10:37 am

Hi Marco,

There is an example in our Dyalog DotNet Interface guide about using .NET to send an email.

The example uses system.web.mail, but Microsoft now recommend that a system.net.mail is used instead.

Regards,

Vince
Vince|Dyalog
 
Posts: 432
Joined: Wed Oct 01, 2008 9:39 am

Re: Sending emails

Postby Gantois on Wed Oct 29, 2014 12:31 am

Hi Vince,

Thanks for you reply. I'll study,

Marco
Gantois
 
Posts: 89
Joined: Thu Apr 17, 2014 9:44 am

Re: Sending emails

Postby Gantois on Fri Mar 11, 2016 3:10 pm

Hi Vince!

Returning to this subject, I have tryed sending email using the .Net Interface Guide example as following, but without success. What is my mistake? Is it necessary some configuration in my computer before ? I intend to use it in a website (miserver and component files).

Could You help me again?


⎕USING←'System.Web.Mail,System.Web.dll'
m←⎕NEW MailMessage
m.From←'marcogantoisnotospam@hot-mail.com'
m.To←'gutao1234notospam@g-mail.com'
m.Subject←'order'
SmtpMail.Send m
The message error is:
EXCEPTION: the configuration value "SendUsing" is invalid.

Thanks,
Marco Gantois
Gantois
 
Posts: 89
Joined: Thu Apr 17, 2014 9:44 am

Re: Sending emails

Postby Gantois on Fri Mar 11, 2016 3:51 pm

Hi Vince,

About the above case (last repply)

A) The exception was:

⎕exception
System.Web.HttpException: O valor de configuração "SendUsing" é inválido.

---> System.Reflection.TargetInvocationException: Uma exceção foi acionada pelo destino de uma chamada. ---> System.Runti

--- Fim do rastreamento de pilha de exceções internas ---

em System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] by

em System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] provi

em System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)

--- Fim do rastreamento de pilha de exceções internas ---

em System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
em System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
em System.Web.Mail.SmtpMail.Send(MailMessage message)
me.InteropServices.COMException (0x80040220): O valor de configuração "SendUsing" é inválido.
refModifiers, Int32 culture, String[] namedParameters)
dedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)



B) I have tried changing from: ⎕USING←'System.Web.Mail,System.Web.dll'
to ⎕USING←'System.Net.Mail,System.Net.dll'

⎕USING←'System.Net.Mail,System.Net.dll'
m.From←'marconotospamgantois@hot-mai.com'
m.To←'gutaonotospam1234@g-mail.com'
m.Subject←'order'
m.Body←'Send me 100 copies of Dyalog APL now'
SmtpMail.Send m
VALUE ERROR
SmtpMail.Send m


Thanks,
Marco
Gantois
 
Posts: 89
Joined: Thu Apr 17, 2014 9:44 am

Re: Sending emails

Postby Jinny on Sun Apr 21, 2019 8:27 pm

Help - I'm having trouble sending emails from my Mipage too :-(

This is what I have written as part of my Callback function:

⎕USING←'System.Web.Mail,System.Web.dll'
⍝ OR ? ⎕USING←'System..Mail,System.Web.dll' (this did not work at all, it returned a value error for MailMessage on the next line)
m←⎕NEW MailMessage
m.Subject←'order'
m.Body←'send me 100 copies'
m.From←'annabelnotospam@s-k-y.com'
m.To←'jinnynotospam@s-k-y.com'
SmtpMail.Send m


It runs through to the last line where this occurs:
*** MiServer Debug ***
EXCEPTION
CallbackFn[38] SmtpMail.Send m


It also seems to me that something must be missing as I could be sending emails from any email address as I have not entered a user password?

Many thanks, Jinny
Jinny
 
Posts: 31
Joined: Sun Jul 01, 2018 10:15 am

Re: Sending emails

Postby Vince|Dyalog on Tue Apr 23, 2019 10:01 am

Hi Jinny and Marco,

Marco, I am sorry for not answering your last posts on this thread last time! Please email me a reminder at support if that happens again.

Jinny, I have created a function named trynetmail for this and the following code works:

      trynetmail;⎕USING;⎕IO;⎕ML;m;ma;client
⎕USING←,⊂''
⎕USING,←⊂'System.Net.Mail,System.dll'
⎕USING,←⊂'System'
⎕ML←⎕IO←1

m←⎕NEW MailMessage
ma←⎕NEW MailAddress(⊂'support@dyalog.com')
m.From←ma
ma←⎕NEW MailAddress(⊂'support@dyalog.com')
m.To.Add ma
m.Subject←⊂'Hello world from Dyalog'
m.Body←⊂'This is my test email'


client←⎕NEW SmtpClient(⊂'smtp.yourSMTPServer.com')
client.Send m


By the way, I would advise against putting your real email address (and that of Annabel) in a public forum. I think Spammers get such email addresses and spam them, or use them as fake email addresses for sending SPAM.

I have edited the posts in this thread to disguise the email addresses.

Regards,

Vince
Vince|Dyalog
 
Posts: 432
Joined: Wed Oct 01, 2008 9:39 am

Re: Sending emails

Postby Jinny on Wed Apr 24, 2019 8:02 am

Hi Vince,
Many thanks for the advice, it runs through fine till the last line and then:

*** MiServer Debug ***
EXCEPTION
CallbackFn[53] client.Send m


I'm wondering whether I need to declare the sender email address anywhere and provide the password? Help!

It was very kind of you to edit my email addresses to avoid my being inundated with Spam - thank you, Jinny
Jinny
 
Posts: 31
Joined: Sun Jul 01, 2018 10:15 am

Re: Sending emails

Postby Vince|Dyalog on Fri Apr 26, 2019 10:24 am

Hi Jinny,

When you get a .NET Exception, try to see if there is anything interesting in

⎕Exception
and
⎕exception.InnerException.

You can read more about the SmtpClient class here:
https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient.-ctor?view=netframework-4.6.1

In the example they have there, they do say something about Credentials.

Regards,

Vince
Vince|Dyalog
 
Posts: 432
Joined: Wed Oct 01, 2008 9:39 am

Re: Sending emails

Postby Jinny on Wed Aug 11, 2021 6:40 pm

Hi there,

I never did manage to send emails from my APL code. I shelved it as I figured that it might be blocked because I was working on an NHS computer.

However, now I have reached the point where I have to return to the problem. I've moved all my APL to a different computer which doesn't have organisation-imposed blocks.

It looks as though nodemail may be the easiest way to send emails from my code? Can I use this with APL? I'm a bit out of my depth about how they would relate, would I simply enclose nodemail commands in an 'Add _.script ScriptFollows' section?

Many thanks for any advice,
Jinny
Jinny
 
Posts: 31
Joined: Sun Jul 01, 2018 10:15 am

Next

Return to MiServer

Who is online

Users browsing this forum: No registered users and 1 guest