1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Send data from Outlook to a web page

Discussion in 'Visual Basic ( VB )' started by Var_ST, Aug 29, 2007.

  1. Var_ST

    Var_ST New Member

    Joined:
    Aug 29, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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
    ----------------- ~~~~~ -----------------
     
    Last edited by a moderator: Aug 30, 2007

Share This Page