Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Automate email generation client side using VBScript

Posted on 2009-07-13
2
Medium Priority
?
614 Views
Last Modified: 2012-05-07
I need to automate the generation of an email from an intranet web page.  This email needs to be created cient side, as the senders will need to be able to review the mail and attachments before it is sent, and it needs to go from their own account and be filed in their sent items etc. I am working with office 2007, but my users are on a mixture of office 2003 and 2007.

I have found that I am not able to automate outlook from IE using VBScript.  When I try to create an instance of an outlook application, I get an error that the activeX object cannot be created . I assume this must be a security feature as I can automate outlook from Excel and Access. I don't know if there is a way around this, but I have failed to find one so far.

I am able to automate word from IE, so I thought as a workaround i may be able to create the email in Word.  This script works fine and creates and the email using word when outlook is closed, but when outlook is open it fails when I try to display the envelope information. When this happens, if I go into the word app that is created and try to manually set the envelopevisible property to true, I get an error -2147467259 (80004005).

I'm getting a bit stumped now and would be grateful for any ideas?

Thanks
Phil
sub window_onLoad()
        
            dim app, doc
            set app = createobject("Word.Application")
            app.Visible = true
            doc = app.Documents.Add
            
            'Set body text
            app.ActiveDocument.Range.Text = "Text Area"
 
            'Set mail details
            app.ActiveWindow.EnvelopeVisible = True
            app.ActiveDocument.MailEnvelope.Item.Recipients.Add document.getElementById("<%=MailTo.ClientID%>").Value
            app.ActiveDocument.MailEnvelope.Item.Subject = document.getElementById("<%=MailSubject.ClientID%>").Value
            app.ActiveDocument.MailEnvelope.Item.Attachments.Add "C:\test.txt"
 
            'Close window
            self.close()
  
        end sub

Open in new window

0
Comment
Question by:phillarby
2 Comments
 
LVL 18

Expert Comment

by:exx1976
ID: 25017866
You need to use Outlook Redemption.

http://www.dimastr.com/redemption/

HTH,
exx
0
 

Accepted Solution

by:
phillarby earned 0 total points
ID: 25020560
Sadly that is not an option.

In the end I sent the mails server side to the users, who could then check them before forwarding on to their intended recipients.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question