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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in Sending Email 2

Status
Not open for further replies.

pandi

Programmer
Dec 12, 2001
22
0
0
MY
Dear all

I am using Microsoft office - Outlook web access as client and Exchange server 2003 as our server. Now my problem is I need to send email from my VB6 application. Due to Outlook web access I am not able to use MAPI Control. Any other ideas of sending email? Need to be solved ASAP.

Thanks in advance
 
try this function:

Code:
Sub SendMail (Byval SMTPipaddress, ByVal strRecipientsList, ByVal strFilePath)
	Dim strSubj, strBody
	Dim objMessage, objConfig, objCfgFields
	
	strSubj = "This is the subject"
	strBody = "This is the email body text"

	Set objMessage = CreateObject("CDO.Message")
	Set objConfig = objMessage.Configuration
	Set objCfgFields = objConfig.Fields
	objCfgFields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = SMTPipaddress
	objCfgFields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2 'cdoSendUsingPort
	objCfgFields.Update
	
	'Creating a new Message
	objMessage.From = "YourMail@Domain.com"
	objMessage.Subject = strSubj & Now
	objMessage.TextBody = strBody
	objMessage.To = strRecipientsList
	objMessage.AddAttachment strFilePath
	objMessage.Fields.Update
	objMessage.Send
	
	set objMessage = Nothing
	set objConfig = Nothing
	set objCfgFields = Nothing
End Sub

Hope this helps...

--------------------------------------
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
 
I use vbSendMail occasionally without problems. I began using it to avoid the user having to click OK when the prompt about a program trying to send an Email pops up. You can learn about it with examples here:


Once you add the DLL it's as easy as:

Code:
Set poSendMail = New clsSendMail
With poSendMail
        .SMTPHost = "Mail.YourDomain.com"
        .From = "DrEmail@Widget.com"
        .FromDisplayName = sFirm
'        .FromDisplayName = "The Widget Corporation"
        .AsHTML = True
        .Message = sBody
        .Recipient = sTo
'        .Subject = "The Widget Corporation - Patient Follow-ups for: " & Format(dCurrentDate, "MM/DD/YYYY")
        .Subject = sFirm

        .Send
    End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top