Rule to send subject line as text message to phone

Hello experts,

Is there a way to send just the subject line of all incoming messages to my phone by use of a rule or macro?

I don't want to simply forward the subject and body like I can already do using this:

Sub NewSMS(Item As Outlook.MailItem)
    Dim olkMsg As Outlook.MailItem
    If Weekday(Date) = vbTuesday Then
        Set olkMsg = Item.Forward
        'Change the email address on the following line'
        olkMsg.Recipients.Add "5555551212@txt.att.net"
        olkMsg.Send
    End If
LVL 1
PhosphorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TheGorbyCommented:
I THINK this will work, I haven't tested it.
Sub CheckDay(Item As Outlook.MailItem)
    Dim olkMsg As Outlook.MailItem
    If Weekday(Date) = vbTuesday Then
        Set sSubj = olkMsg.Subject
    End If
End Sub
Sub NewSMS(Item As Outlook.MailItem)
    Dim olkMsg2 As Outlook.MailItem
    Set olkMsg2 = Outlook.Application.CreateItem(olMailItem)
    With olkMsg2
        .To = "5555551212@txt.att.net"
        .Body = sSubj
        .Subject = ""
        .Send
    End With
End Sub

Open in new window

PhosphorAuthor Commented:
I get a "Compile error" message,

If Weekday(Date) = vbTuesday Then
        Set sSubj = olkMsg.Subject << the word Subject is highlighted.
TheGorbyCommented:
Sorry, that's what I get for not testing! This I've tested and should work just fine:
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

Open in new window

Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

PhosphorAuthor Commented:
Yes, that shows promise, unfortunately my default email is not the account I need to send from.
I am behind an exchange server and need to use my pop3 account to send. Is there a way to specify which account?
TheGorbyCommented:
So these emails are received via your Exchange account, but you want to send the subject of those emails using your POP3 account?

Or are the emails received using POP3 and sent using POP3 as well? (all within the same POP3 account)
TheGorbyCommented:
Which version of Outlook are you using?
PhosphorAuthor Commented:
Yes, my exchange account is my inbox and I have a secondary Pop account.

I'm currently using Outlook 2007.
TheGorbyCommented:
Well I don't have a copy of '07 to test on, but starting in '07 Outlook is able to use the '.SendUsingAccount' property. Hopefully the example below is correct, if not here are some sites concerning its use:

http://www.pcreview.co.uk/forums/thread-3828711.php
http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_23170205.html
http://www.eggheadcafe.com/software/aspnet/35932219/outlook-automation--sendusingaccount-readonly.aspx
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 = ""
            .SendUsingAccount = "Account Name"
            .Send 
        End With 
    End If 
     
    Set olkMsg = Nothing 
 
End Sub

Open in new window

TheGorbyCommented:
Some other methods to try:

--  Removing line 17 completely

--  .SendUsingAccount = "address@domain.com"

--  .SendUsingAccount.SmtpAddress = "address@domain.com"
PhosphorAuthor Commented:
Thanks, I haven't looked at the examples yet.
TheGorbyCommented:
This looks like the best option, change your account number accordingly.

http://www.outlookcode.com/codedetail.aspx?id=1359
.SendUsingAccount = Application.Session.Accounts(2)

Open in new window

PhosphorAuthor Commented:
How is the enumeration determined?
PhosphorAuthor Commented:
I've tried most things I can think of, tried different enums  for .SendUsingAccount = Application.Session.Accounts(2).

Nothing works yet.
Don't know what to do 'cept read more things...
TheGorbyCommented:
It's a shame I can't test that myself, not knowing is bugging the hell out of me! The only other thing I can think of is something called Outlook Redemption (http://www.dimastr.com/redemption/). I've never used it myself, but from what I understand it adds extra functions and properties to Outlook that allow you to easily manipulate which account to send from, using VBA.
PhosphorAuthor Commented:
Yeah, I was reading up on that last night. I had heard before that it helps get beyond certain security thresholds but never explored using it.
Though if I could somehow have an action to simply take the subject line, SenderName & ReceivedTime to be dumped into a text file into a directory I could VBScript it no problem...
TheGorbyCommented:
Well shucks, that's no problem! Just make sure your VBScript deletes the file after it's done, the VBA script will fail if the txt file already exists.
Sub NewSMS(Msg As MailItem)
      
    Dim strID As String
    Dim olkMsg As Outlook.MailItem
    Dim strExportFileName As String
    Dim objFSO
    Dim objFile
      
    If Weekday(Date) = vbWednesday Then
        strExportFileName = "C:\tempfile.txt"
        strID = Msg.EntryID
        Set olkMsg = Application.Session.GetItemFromID(strID)
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.CreateTextFile(strExportFileName, False)
        objFile.Writeline (olkMsg.Subject & vbCr)
        objFile.Writeline (olkMsg.SenderEmailAddress & vbCr)
        objFile.Writeline (olkMsg.ReceivedTime)
        objFile.Close
        Set objFSO = Nothing
        Set objFile = Nothing
    End If

End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TheGorbyCommented:
Or if you DO want it to overwrite the file, change line 14 accordingly:
Set objFile = objFSO.CreateTextFile(strExportFileName, True)

Open in new window

PhosphorAuthor Commented:
My plan right now is to take the ReceivedTime variable and replace all filename unfriendly chars to dynamically set a unique filename, My exchange server D/Ls from the pop3 accounts every 15 mins. and there may be 10-15 emails so when they arrive, the folder watcher script should open the newly created text-file and CDO email them as they arrive. After the email is sent, the base file will be either moved -or- deleted. not figured that out yet...

Thanks a bunch!
PhosphorAuthor Commented:
Thanks, I've never really meesed with VBA because VBS usually handles all my needs. You definitely earned your points...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.