Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Send data from Outlook to a web page (http://www.go4expert.com/forums/send-data-outlook-web-page-t6107/)

Var_ST 29Aug2007 23:30

Send data from Outlook to a web page
 
Hi,
I am trying to capture the data (To, From, Subject and Message) from an outgoing email from MS Outlook. The data capture will be sent to a web page by GET method.

The below code is initiated when the user click the Macro button 'Send and Add'. As soon as the user click the Macro the data must be captured and send to the web page and than send the email. The only problem is that when there is a ; (semi colon) in the 'To:' field i can't get the Email address. I tried to Replace the ; using Replace() function but it doesn't work.

Any idea would be helpful.


----------------- ~~~~~ -----------------
Code:

Sub SENDandADD()

    Dim MailTo As String
    Dim MailFrom As String
    Dim MailSubject As String
    Dim MailMessage As Variant
   
    Set objOutlook = CreateObject("Outlook.Application")
    Set objItem = objOutlook.ActiveInspector.CurrentItem
   
    'CAPTURE THE DATA
    MailTo = objItem.To
    MailFrom = "Jack Nick"
    MailSubject = objItem.Subject
    MailMessage = objItem.Body
   
    'REPLACE THE ; FROM THE TO FIELD
    MailTo = Replace(MailTo, ";", "")
    MsgBox (MailTo)
   
    'THE WEBSITE TO GO
    Dim URL
    URL = "www.some-website.com"
   
    'ONLY FOR IE
    Dim IE
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = 1
   
    'PASS THE CAPTURED DATA BY GET METHOD
    IE.navigate ("http://" + URL + "?toEmail=" + MailTo + "&fromEmail=" + MailFrom + "&subject=" + MailSubject + "&message=" + MailMessage)

    'SEND EMAIL
    objItem.Send

End Sub

----------------- ~~~~~ -----------------


All times are GMT +5.5. The time now is 12:52.