PDA

View Full Version : Sending Email? (CreateObject Problem??)


craigp
28-09-2007, 07:38 AM
Hi all,

I have a requirement for a simple XML Web Service (.NET v2) to send emails. I had a quick go yesterday but I am getting a security error when I try to create the object (late binding):

Dim mail As Object = CreateObject("Persits.MailSender")
Dim mail As Object = CreateObject("Dundas.Mailer")

The exception is:

Server was unable to process request. ---> Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Is this a configuration problem with my hosting or am I doing something else wrong?

Cheers!

Craig

craigp
28-09-2007, 10:48 AM
Hmmm ... I just tried the following and still get the same security exception:

PublicSharedSub SendMail(ByVal FromAddr AsString, ByVal FromName AsString, ByVal ToAddr AsString, ByVal Subject AsString, ByVal Body AsString)
Dim mail AsNew MailMessage()
With mail
.From = New MailAddress(FromAddr, FromName)
.To.Add(ToAddr)
.Subject = Subject
.Body = Body
EndWith
Dim smtp AsNew SmtpClient("localhost")
'smtp.Credentials = New Net.NetworkCredential("EMAIL ADDRESS", "PASSWORD")
smtp.Send(mail)
EndSub

Carl Shepherdson
28-09-2007, 11:49 AM
Submit a ticket to support with the domain and how to replicate the error.