?
Solved

Sending mail through VB

Posted on 2003-03-24
11
Medium Priority
?
211 Views
Last Modified: 2010-05-01
hello,
        I want send the email message with attachements throug vb.

Is there any simple way achive this one.

or If any one knows sendObject method.....



Please help me...

Advance Thanks...............


Maria
0
Comment
Question by:maaria_1978
[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
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 13

Expert Comment

by:AlbertaBeef
ID: 8200144
I like vbSendMail:  this is a good one:

http://www.freevbcode.com/ShowCode.Asp?ID=109
0
 
LVL 18

Accepted Solution

by:
Sethi earned 80 total points
ID: 8200197
As AlbertaBeef said - the easiest way to send emails or SMS through VB is by using vbSendMail DLL that can be freely downloaded from this site:
http://www.freevbcode.com/ShowCode.Asp?ID=109

The other is using MAPI controls on VB. Look at the following links for tutorial and sample code of MAPI.
Use the following links to understand MAPI:
http://abstractvb.com/code/code713.asp
http://www.thescarms.com/vbasic/MapiEmail.asp

There are two other ways:
1.     CDO
2.     Outlook Objects
These two require certain applications like Microsoft Outlook or Exchange server to work efficeintly.
0
 
LVL 4

Assisted Solution

by:Dangeriz
Dangeriz earned 80 total points
ID: 8201892
Hi,

Here's a simple code snippet that does the job:

First set a reference to Microsoft CDO 1.21 library.

'set the variables
Dim MySession As Session
Dim Mymsg As Message
Dim Mymessagecol As Messages
Dim Myrecipscol As Recipients
Dim Myrecip As Recipient
Dim Myattcol As Attachments
Dim Myatt As Attachment

Set MySession = New Session

'first get a session to loggin onto MAPI/CDO
MySession.Logon "MS Exchange Settings", "", False, True

Set Mymessagecol = MySession.Outbox.Messages
Set Mymsg = Mymessagecol.Add
Mymsg.Subject = "Test message"
Mymsg.Text = "This is a test"

' recipient
Set Myrecipscol = Mymsg.Recipients
Set Myrecip = Myrecipscol.Add
       
Myrecip.Address = "someone@somewhere.com"
Myrecip.Resolve
Myrecip.Type = CdoTo
       
' attachments
Set Myattcol = Mymsg.Attachments
Set Myatt = Myattcol.Add
       
Myatt.Position = 0
' the name of the attachment is the full path of the file
Myatt.Name = "C:\test.doc"
Myatt.Type = CdoFileData  

Myatt.Source = "C:\test.doc"
Myatt.ReadFromFile ("C:\test.doc")
             
Mymsg.Update
Mymsg.Send

MySession.Logoff





0
Industry Leaders: 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!

 

Expert Comment

by:CleanupPing
ID: 9056259
maaria_1978:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 9063859
Recommendation: Split points between AlbertaBeef, Sethi &  Dangeriz
0
 
LVL 13

Expert Comment

by:AlbertaBeef
ID: 9063946
Only 40 points, hard to split.  Personally don't need 'em, so whatever happens I'm fine with.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9441138
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Split between Sethi and Dangeriz

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9441141
Aye, aye, AB
0
 
LVL 13

Expert Comment

by:AlbertaBeef
ID: 9443199
Aye, Aye??  What're you a pirate suddenly??  Lol.  
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9443256
Don't tell me you're landlocked?  oh, wait...
:)
0
 
LVL 4

Expert Comment

by:Dangeriz
ID: 9449802
Aye aye mateys. Me thinks the lassie has run off with the loot :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

777 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