Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel VBA Send Text Message

Posted on 2011-02-19
5
Medium Priority
?
1,346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34934132
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 2000 total points
ID: 34934145
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:Christian de Bellefeuille
ID: 34934155
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
ID: 34934656
@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
ID: 34968292
Nice.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

604 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