Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Sending mail through VB

Posted on 2003-03-24
11
Medium Priority
?
216 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
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 13

Expert Comment

by:Glen A.
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:Glen A.
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:Glen A.
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

564 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