Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send email script in html?

Status
Not open for further replies.

FK122

Programmer
May 6, 2005
6
CA
Hi there,

I've got a script to send an email out to whoever, and it works fine if I just run the script. However, I want to run the script from a button inside an html page. When I click on the "send email button", I get a "permission denied" error for the objEmailConfig.Fields property. Here's my script:

Code:
Function fGenerateEmail()

    Dim objEmailConfig
    Dim objEmail
    
    Dim sBody
    Dim sTitle
    Dim sFrom
    Dim sTo

    Set objEmailConfig = CreateObject("CDO.Configuration")

    '  "Permission denied" error on the next line.
    objEmailConfig.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
    objEmailConfig.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "smtp_server"
    objEmailConfig.Fields.Update
    
    Set objEmail = CreateObject("CDO.Message")
    objEmail.Configuration = objEmailConfig
    objEmail.From = "me@mydomain.com"
    objEmail.To = "my@buddy.com"
    objEmail.Subject = "subject"
    objEmail.TextBody = "body"
    objEmail.Send

End Function

I think it might have something to do with the security settings of internet explorer, but that's not something I can change. The idea behind this is that this script will be run on different machines on my company's intranet, so there are company-wide security restrictions on IE. Is this the problem? Or am I missing something? Any way around this?

Thanks,
FK
 
Have you tried an HTA ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I didn't even know what an HTA was, to tell you the truth, but I figured it out and got that working. However, I'd much prefer to have it in a standard internet explorer window, if it's at all possible; *is* it possible?

Thanks again,
FK
 
Another option would be to move the email code to a second web page so it would execute right away and have your button send the user to that page. A Response.Redirect ould then send them back to wherever you wanted or display a message that the mail was sent.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top