Solved

Excel VBA Send Text Message

Posted on 2011-02-19
5
1,317 Views
Last Modified: 2013-12-18
Using Outlook email how to send a text message (not a workbook)
I tried the code below but I get "Object Required" error
Regards
Brian
Sub DoneMessage()
    Options.SendMailAttach = False
    ActiveWorkbook.SendMail _
    Recipients:=[TenDigitPhoneNumber] _
        & "@" &   [TextMessageDomain],  _
    Subject:=[SubjectLine]
End Sub

Open in new window

0
Comment
Question by:canesbr
5 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
Are you planning to send the SMS? Are you planning to use MOSA?

Sid
0
 
LVL 13

Assisted Solution

by:George K.
George K. earned 500 total points
Comment Utility
Try this code


 Dim myrange As Range
    Dim myApp As Object
    Dim myMail As Object

    Set myrange = Nothing

     '...    for visible cells selected
    Set myrange = Selection.SpecialCells(xlCellTypeVisible)

   
    If myrange Is Nothing Then
        MsgBox "select a range" ", vbOKOnly
        Exit Sub
    End If

    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With

    Set myApp = CreateObject("Outlook.Application")
    Set myMail = OutApp.CreateItem(0)



 With myMail
        .To = "someone@hotmail.coml"
        .CC = ""
        .BCC = ""
        .Subject = "A Subject here"
' in the follwing you can also add some simple text
        .HTMLBody = RangetoHTML(myrange )
        .Send  
    End With
.....
0
 
LVL 10

Expert Comment

by:cdebel
Comment Utility
1st: Options is undefined
2nd: From what i've read, SendMailAttach seams to be linked to Word Interop... (http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.options.sendmailattach(office.11).aspx)

Try to dump that line and see if it does what you want.
0
 

Accepted Solution

by:
canesbr earned 0 total points
Comment Utility
@georgekl
Thanks - just fixed typo
You had Set myMail = OutApp.CreateItem(0)
Should be Set myMail = myApp.CreateItem(0)
Code below works fine.
Regards
Brian
Sub SendTextMessage()
    Dim myApp As Object
    Dim myMail As Object
    Set myApp = CreateObject("Outlook.Application")
    Set myMail = myApp.CreateItem(0)
    With myMail
        .To = [MessageAddress]
        .CC = ""
        .BCC = ""
        .Subject = [MessageSubject]
        .HTMLBody = [MessageText]
        .Send
    End With
End Sub

Open in new window

0
 

Author Closing Comment

by:canesbr
Comment Utility
Nice.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Nearly six years ago I was hired by a company to be their senior server engineer. One of my first projects was to implement Exchange Server 2007 on a Windows Server 2008 Single Copy Cluster for high availability. That was the easy part; read on to l…
New-MailboxSearch Powershell Command and step by step approach to Search and Extract Emails form Exchange 2013 Journaling server.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now