Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send email

Status
Not open for further replies.

HaveTrouble

Programmer
Jan 10, 2005
63
US
What's the best way to send email from VB 6.0 ? I tried CDO but it won't work if there is attachment with file size > 4M. I tried outlook but it works in 1 server but not the other. Below are the codes for outlook. It errors out in .send:


Set objMail = appOutlook.CreateItem(0)
objMail.To = sEmailTo
objMail.Subject = EmailSubject
objMail.Body = EmailBody

'= if has more than one file to attach, send the file in as
'= file1;file2;file3....
If Not IsMissing(sAttachmentPath) Then
glo_objs = Split(sAttachmentPath, ";")
For Each glo_obj In glo_objs
objMail.Attachments.Add glo_obj
Next
End If
objMail.Send

any suggestion ??
 
This works for me:

' Start Outlook.
' If it is already running, you'll use the same instance...
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")

' Logon. Doesn't hurt if you are already running and logged on...
Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon , , True

' Send a message to your new contact.
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
' Fill out & send message...
olMail.Subject = "My Subject"
olMail.Body = "My message"

' Add an attachment
olmail.Attachments.Add "my source"

olMail.To = strAddress
olMail.Send
olNs.Logoff
Set olNs = Nothing
Set olMail = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top