Link to home
Start Free TrialLog in
Avatar of dangermound
dangermound

asked on

Problem running script in MS Office 2007

Hello EE,

I am unable to get Office to run my script properly.  I'm very new to this, so perhaps it is an easy solution.

I want Outlook to send an incoming email's subject line, from, and timestamp to my phone.  I don't have a smartphone but would like to receive new message alerts via text.

I did some browsing on EE and came across code written by: TheGorby
https://www.experts-exchange.com/questions/26704826/Rule-to-send-subject-line-as-text-message-to-phone.html

I paste it into VB (Alt+F11) directly in "ThisOutlookSession".  I save it, close Outlook then I create a rule.  The rule has "no conditions" and an action "run a script".
It says: "run Project1.ThisOutlookSession.NewSMS"

I'm not recieving a text. What am I doing wrong/missing?  Thank you.

***code by TheGorby*** (not included in code)

Sub NewSMS(Msg As MailItem)
    
    Dim strID As String
    Dim strSubj As String
    Dim objMsg As Outlook.MailItem
    
    If Weekday(Date) = vbTuesday Then
        strID = Msg.EntryID
        Set olkMsg = Application.Session.GetItemFromID(strID)
        strSubj = olkMsg.Subject
        Set olkMsg = Application.CreateItem(olMailItem)
        With olkMsg
            .To = "5555551212@txt.att.net"
            .Body = strSubj
            .Subject = ""
            .Send
        End With
    End If
    
    Set olkMsg = Nothing

End Sub

***code by TheGorby*** (not included in code)

Open in new window

Avatar of dangermound
dangermound

ASKER

I don't even care about the message info. A text that simply reads, "New Message" would be optimum.
Avatar of Chris Bottomley
In the VB editor of outlook insert | MOdule

Now move your sub to this module and check the rule is updated ... then retry.

Chris
>>>I'm not recieving a text. What am I doing wrong/missing?  Thank you.

Tha code will work from "ThisOutlookSession" :)

I believe your macros are disabled :)

Sid
ASKER CERTIFIED SOLUTION
Avatar of SiddharthRout
SiddharthRout
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was it. Thank you!