Solved

Excel VBA Send Text Message

Posted on 2011-02-19
5
1,320 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
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 500 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:cdebel
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vlookup nonexact IP address match 32 54
FormulaArray VBA Issue 6 18
Update As Well As Add 6 42
Easy Excel formula needed 4 28
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
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…

863 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

20 Experts available now in Live!

Get 1:1 Help Now