Solved

Send Outlook message to SQL server via toolbar button

Posted on 2007-11-13
5
254 Views
Last Modified: 2010-04-08
I want to create a toolbar button in Outlook that will allow me to take a highlighted e-mail in Outlook and pass the body and subject of the message to a Web form?

I am currently copying and pasting the content into the form fields and I want to now automate this process.

Thanks
0
Comment
Question by:xactdesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 20275823
Hi, xactdesign.

There are several ways to do this.  You could do it through a web service or you could write directly to the SQL database using something like ADO.  
0
 
LVL 2

Author Comment

by:xactdesign
ID: 20276422
OK.  I would preferably like to do it through ADO but I need a way to associate the e-mail to a customer prior to inserting the record.  I felt that passing it to a Web form and then selecting the customer from a drop down would be easiest.  I really don't care how I get there, I am just trying to eliminate copying and pasting these e-mails into text fields.

The SQL server is on a remote host, not local.  This is another reason for wanting to send the message body and subject to a form on my Web site and then submitting it.

I would appreciate some examples of how to accomplish this, that would help me so much.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 20277213
This will do the job.  You can run it from inside Outlook.

Sub FillFormFields()
    Dim objIE As Object, _
        objField1 As Object, _
        objField2 As Object, _
        olkMsg As Outlook.MailItem
    'Get the currently selected message in Outlook
    Set olkMsg = Application.ActiveExplorer.Selection(1)
    'Create an instance of IE
    Set objIE = CreateObject("InternetExplorer.Application")
    'Open the web page.  Change the URL as needed.
    objIE.Navigate2 "http://company.com/pagename.asp"
    Do Until objIE.readyState = 4
        DoEvents
    Loop
    'Get the two fields you want to fill in on the web page.  Change the field names as needed.
    Set objField1 = objIE.Document.getElementById("FieldName1")
    Set objField2 = objIE.Document.getElementById("FieldName2")
    'Fill the fields in with data from the mailitem
    objField1.Value = olkMsg.Subject
    objField2.Value = olkMsg.Body
    'Display IE
    objIE.Visible = True
    'Clean-up
    Set objIE = Nothing
    Set objField1 = Nothing
    Set objField2 = Nothing
End Sub
0
 
LVL 2

Author Comment

by:xactdesign
ID: 20277380
Hey thanks for the code.

When I run the code in Outlook I get the following error:

Runtime Error 91

Object variable or with bloack variable not set

on this line
 objField1.Value = olkMsg.Subject
0
 
LVL 2

Author Comment

by:xactdesign
ID: 20277471
Nevermind, I forgot to upload my web page.  It worked great.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

626 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