• 0

[VB 6] Sending E Mail Code


Question

Hi all, Is there any code that I can use in my VB program so that I can send an e mail specifying an SMTP server. The thing is that the computer I am trying to send e mails from has not got an E Mail account set up; I just want it to send e mails like alerts when certain things happen.

Link to comment
https://www.neowin.net/forum/topic/387666-vb-6-sending-e-mail-code/
Share on other sites

1 answer to this question

Recommended Posts

  • 0

EDIT: I would either download a free smtp server such as postcast server or i would write some code to look up the mx record of the host after the @ symbol. either way the smtp conversation remains the same. i misread your post the first time i scanned it. with postcast you would connect to 127.0.0.1 or you would connect to what ever host you got from the mx record of say... yahoo.com here is an example output of nslookup looking for an mx record

C:\Documents and Settings\Yo>nslookup
Default Server:  rtr1.randmpc.com
Address:  192.168.4.1

> set type=MX
> yahoo.com
Server:  rtr1.randmpc.com
Address:  192.168.4.1

Non-authoritative answer:
yahoo.com       MX preference = 1, mail exchanger = mx1.mail.yahoo.com
yahoo.com       MX preference = 1, mail exchanger = mx2.mail.yahoo.com
yahoo.com       MX preference = 1, mail exchanger = mx3.mail.yahoo.com
yahoo.com       MX preference = 5, mail exchanger = mx4.mail.yahoo.com

yahoo.com       nameserver = ns4.yahoo.com
yahoo.com       nameserver = ns5.yahoo.com
yahoo.com       nameserver = ns1.yahoo.com
yahoo.com       nameserver = ns2.yahoo.com
yahoo.com       nameserver = ns3.yahoo.com
mx1.mail.yahoo.com      internet address = 4.79.181.14
mx1.mail.yahoo.com      internet address = 4.79.181.15
mx1.mail.yahoo.com      internet address = 67.28.113.10
mx1.mail.yahoo.com      internet address = 67.28.113.11
mx2.mail.yahoo.com      internet address = 4.79.181.13
mx2.mail.yahoo.com      internet address = 67.28.114.35
mx2.mail.yahoo.com      internet address = 67.28.114.36
mx2.mail.yahoo.com      internet address = 4.79.181.12
mx3.mail.yahoo.com      internet address = 64.156.215.6
mx3.mail.yahoo.com      internet address = 64.156.215.8
mx3.mail.yahoo.com      internet address = 64.156.215.18
mx3.mail.yahoo.com      internet address = 67.28.113.19
mx3.mail.yahoo.com      internet address = 64.156.215.5
mx4.mail.yahoo.com      internet address = 68.142.202.12
mx4.mail.yahoo.com      internet address = 66.218.86.156
mx4.mail.yahoo.com      internet address = 68.142.202.11
ns1.yahoo.com   internet address = 66.218.71.63
ns2.yahoo.com   internet address = 66.163.169.170
ns3.yahoo.com   internet address = 217.12.4.104
> gmail.com
Server:  rtr1.randmpc.com
Address:  192.168.4.1

Non-authoritative answer:
gmail.com       MX preference = 10, mail exchanger = gsmtp83-2.google.com
gmail.com       MX preference = 10, mail exchanger = gsmtp185-2.google.com
gmail.com       MX preference = 5, mail exchanger = gmail-smtp-in.l.google.com
gmail.com       MX preference = 10, mail exchanger = gsmtp83.google.com
gmail.com       MX preference = 10, mail exchanger = gsmtp163.google.com
gmail.com       MX preference = 10, mail exchanger = gsmtp185.google.com

gmail.com       nameserver = ns2.google.com
gmail.com       nameserver = ns3.google.com
gmail.com       nameserver = ns4.google.com
gmail.com       nameserver = ns1.google.com
gmail-smtp-in.l.google.com      internet address = 72.14.205.27
gsmtp83.google.com      internet address = 66.249.83.27
gsmtp163.google.com     internet address = 64.233.163.27
gsmtp185.google.com     internet address = 64.233.185.27
gsmtp83-2.google.com    internet address = 66.249.83.114
gsmtp185-2.google.com   internet address = 64.233.185.114
ns1.google.com  internet address = 216.239.32.10
ns2.google.com  internet address = 216.239.34.10
ns3.google.com  internet address = 216.239.36.10
ns4.google.com  internet address = 216.239.38.10
>

I am guessing that you want to do this for free? if so you can always open a socket and use the following conversation with the smtp server:

PSUEDO EXAMPLE:

Open Socket to MyServer on port 25 as Socket

wait for data beginning with the three chars 220
send helo
waif for data beginning with the three chars 250
send MAIL FROM:<me@mydomain.com>;
wait for data beginning with the three chars 250
send RCPT TO:<someone@something.net>;
wait for data beginning with the three chars  250
send DATA
wait for data beginning with the three chars 354
send your entire message followed by VbCrLf + "." + VbCrLf
Wait for data beginning with the three chars 250
Send quit
wait for data beginnging with the three chars 221
close socket

any other response besides the numbers i indicated above indicates an error or a warning. here is a sample conversation done with telnet 127.0.0.1 25 (because i am on an smtp server)... actually i used it as a reference for writing this post. and all lines must be terminated with a carrige return (vbcrlf or chr$(10,13))

220 user Microsoft ESMTP MAIL Service, Version: 6.0.2600.1 ready at  Tue, 25 Oct 2005 10:56:57 -0400
MAIL FROM:<plaguethenet@gmail.com>;
503 5.5.2 Send hello first
HELO
500 5.3.3 Unrecognized command
helo
250 user Hello [127.0.0.1]
MAIL FROM:<plaguethenet@gmail.com>;
250 2.1.0 plaguethenet@gmail.com....Sender OK
RCPT TO:<plaguethenet@gmail.com>
250 2.1.5 plaguethenet@gmail.com
data
354 Start mail input; end with <CRLF>.<CRLF>

.
250 2.6.0 <USERLkVTkD3a9pzyt5m00000002@user> Queued mail for delivery
help
214-This server supports the following commands:
214 HELO EHLO STARTTLS RCPT DATA RSET MAIL QUIT HELP AUTH BDAT VRFY
quit
221 2.0.0 user Service closing transmission channel


Connection to host lost.

ideally to check the numbers i would wait for 1 line to come throught first then i would check the first 3 chars. sending data when the server isnt ready could result in some rather interesting problems.

and there are plenty of socket tutorials out there. Hope this helped!

Edited by plaguethenet
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • They've been focusing on security and quality? Could have fooled me. Their own paying customers literally just got breached because they failed to push SharePoint updates downstream to on prem servers operating outside of their "365" ecosystem.
    • The animosity is unnecessary, when I opened the page I only saw one response which never mentioned your other steps, and when I hit reply it jumped straight to the bottom and again, I saw no other responses.  I was simply agreeing with the first comment that said yes, you should be fine if you erase its current operating system. Using another PC, or the copy of Windows that comes on that PC (former option is more trustworthy), download and run the Windows Media Creation tool.  It will walk you thru the process of downloading Windows and writing it to a USB stick.  It will even ask you at one point whether you're reinstalling it to the current machine or installing it on another machine. Then just boot the PC in question from that USB stick.  Usually spamming Esc, Del, F-8, F-9, F-10, F-11, F-12 or F-2 immediately after power on will bring up a boot menu, it varies by manufacturer.  If Windows starts booting you either missed your window or hit the wrong key. Follow the on-screen instructions.  When it gets to the disk formatting part I usually just delete all the partitions on the destination drive, then select the unpartitioned space as my destination.  The Windows installer will then automatically partition the drive as needed. Be prepared to download drivers from the PC manufacturer's website, they may not come bundled with Windows and you may not be able to use things like WiFi or ethernet until you have them.  They "might" work straight away, but they also might not.  Better to be prepared with a spare PC and a USB stick to transfer them over.
    • Wise Disk Cleaner 11.2.5 by Razvan Serea Wise Disk Cleaner is a free disk utility designed to help you keep your disk clean by deleting any unnecessary files. Usually, these unnecessary, or junk files appear as a result of program's incomplete uninstalls, or Temporary Internet Files. It is best if these files are wiped out from time to time, since they may, at some point, use a considerable amount of space on your drives. Wise Disk Cleaner, with its intuitive and easy to use interface, helps you quickly wipe out all the junk files. Using the program is indeed easy. It also works fast when both scanning for files and deleting files. The new Wise Disk Cleaner has more advantages: improved performance, better interface and scans/cleans more thoroughly. Wise Disk Cleaner Free provides lifetime free update service and Unlimited Free technical support. The first Slimming System software Wise Disk Cleaner is the first system slimming tool, which will help you to remove Windows useless files that you don't need, such as Korean IME, Windows Sample music, videos, pictures, Installers and Uninstallers of Updates Patches etc. Wise Disk Cleaner 11.2.5 Build 845 changelog: Added cleaning rules for Legacy Games Launcher, Letasoft Sound Booster, Macrium Reflect, MagicLine4NX, MAGIX Photostory, MakeHuman, Max Recorder, Maxprog iCash, Lexware, LG PC Suite, Lightworks, LINE, Listary, and LockHunter. Improved cleaning rules for Xunlei, PowerToys, Meitu, OneDrive, and Tencent Video. For security reasons, users can no longer delete the latest system restore point in the Restore Center. Enhanced System Slimming. Fixed minor bugs from the previous version. Download: Wise Disk Cleaner 11.2.5 | 6.9 MB (Freeware) Download: Portable Wise Disk Cleaner 11.2.5 | 7.3 MB View: Wise Disk Cleaner Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I keep getting ignored when I ask what you guys mean by nuke it. I described the steps and I keep getting the same generic instructions. Can you look at what I have posted multiple times already and validate what I have described? You can't assume everyone has your level of expertise and can interpret your nuking advice. After this many posts in this thread, I don't think we need the same generic advice about just nuke it and reinstall. It's already been said. So can you please outline the specifics? Made in Ukraine? Are you sure?
  • Recent Achievements

    • Week One Done
      Itbob513626 earned a badge
      Week One Done
    • One Month Later
      Itbob513626 earned a badge
      One Month Later
    • Rookie
      EdwardFranciscoVilla went up a rank
      Rookie
    • Week One Done
      MoJo624 earned a badge
      Week One Done
    • Collaborator
      aeganwn earned a badge
      Collaborator
  • Popular Contributors

    1. 1
      +primortal
      618
    2. 2
      ATLien_0
      241
    3. 3
      Xenon
      157
    4. 4
      +FloatingFatMan
      122
    5. 5
      Michael Scrip
      121
  • Tell a friend

    Love Neowin? Tell a friend!