ust select SMTP control from Components ( under project menu (visual basic))

With SMTP 'name for control
.Server = outgoingserver 'Outgoing server name or IP address

.MailFrom = mailFrom 'Sender mail address

.SendTo = mailto 'to whom you want to send mail

.MessageSubject ='Subject of message

.MessageText = mailtext 'mail text

.Attachements.Add attachmentpath 'if you want ot attach any file just give the path here

DoEvents


.Connect

End With

Was This Post Helpful? 0 Back to top
MultiQuote
Quote + Reply

but smtp cotrol does not exist in componants

Dani AI

Generated

A few clarifications tied to the replies by , and so the next steps are clear and practical.

The code shown by sends email (SMTP) — that alone does not guarantee SMS delivery. Public email→SMS gateway addresses are carrier-specific and are increasingly unreliable or blocked; they are being deprecated for commercial/automated use. For a production solution, use an SMS provider API instead. (Twilio on email→SMS deprecation).

Recommended approach and why: sign up with a reputable SMS provider (they provide a sender number/ID, delivery reporting, rate controls and global routing). The provider exposes a REST endpoint for creating messages (example: Twilio’s Messages API) and you invoke that endpoint from your VB6 app. (Twilio Messages API, Plivo SMS overview).

Practical VB6 + Access workflow (high level):

  • Store recipient numbers (and optional carrier) in your Access table; normalize to E.164.
  • Use ADO to read rows and iterate.
  • Make HTTPS calls to the provider’s REST API from VB6 using either MSXML2.ServerXMLHTTP.6.0 or WinHttp.WinHttpRequest.5.1.
  • Record API responses back to the DB, implement rate limiting, retries and error logging, and handle delivery callbacks (webhooks) or poll status when needed. (MS docs: ServerXMLHTTP and WinHttpRequest).

Example VB6 pattern (adapt auth/content to your provider):

Dim http As Object
Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0")
http.Open "POST", "https://api.provider.com/v1/messages", False
http.setRequestHeader "Content-Type", "application/json"
http.setRequestHeader "Authorization", "Bearer YOUR_API_KEY"
http.Send "{""to"":""+14155551212"",""from"":""+1234567890"",""body"":""Test message""}"
If http.Status >= 200 And http.Status < 300 Then
  ' success -> log http.ResponseText
Else
  ' error -> log status, statusText, response
End If

Notes and gotchas: modern providers require TLS 1.2; older Windows may need WinHTTP updates/registry changes to enable TLS 1.2. Test with one number, avoid hard-coding secrets, throttle requests, and log everything. (WinHTTP/ServerXMLHTTP docs and TLS guidance).

References:

Recommended Answers

All 2 Replies

If you are going to use SMTP, you will need to send to a number based on the particular carrier. You would need to use a particular SMS Gateway.

There are other services that you can possibly automate to send to a mobile when you do not know the carrier. http://www.smseverywhere.com/send.htm

Also, can you use VB.NET for this? There are much more elegant solutions if you can.

Hi Shilpa,

The code, you have given is for sending EMails not SMS.
For SMS, you need to use SMS Gateways.. (like GupshupSMS, mvaayoo)

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.