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

Help With VB Sendmail

Status
Not open for further replies.

dennis22

Programmer
Oct 8, 2002
32
Hello Experts!

I have downloaded the vbsendmail project and currently testing the app. Unfortunately the app is returning a message, "The SMTP Host did not respond to the request" and "Valid name, no data record of request type". I just supplied the information in the textboxes of the sample app and click send. What am I doing wrong?


Thanks in advance!
 
Thanks for the reply!

I think I did, the SMTP server was given by my superior, I did something like this before using MS Outlook Automation, as far as I can remember Outlook prompts whenever I send mail (I think..) I dont want that. And I was hoping sendmail.dll would make it easier. I'm a bit confuse here, any help or alternatives regarding sending mail with attachments would be great.


Thanks!
 
Here's code that I use in one of my applications. Possibly you need to use authentication. Is you SMTP a company server, or is it something like Yahoo?
Code:
Public Sub SendEmail(EmailMessage As String)
    Set sendMail = New vbSendMail.clsSendMail
    Dim recipient1 As String
    Dim recipient2 As String
    
    On Error Resume Next
    
    recipient1 = GetSetting(APP_NAME, "Settings", "Recipient1", "Some.Guy@SomeCompany.com")
    recipient2 = GetSetting(APP_NAME, "Settings", "Recipient2", "Another.Guy@SomeCompany.com")
    
    sendMail.SMTPHost = GetSetting(APP_NAME, "Settings", "SMTP")
    sendMail.From = GetSetting(APP_NAME, "Settings", "FromAddress", "")
    sendMail.FromDisplayName = "Automated Email Alert"
    
    'Set authentication properties if required
    If GetSetting(APP_NAME, "Settings", "Authenticate", "0") = "1" Then
        sendMail.Username = GetSetting(APP_NAME, "Settings", "AccountName")
        sendMail.Password = GetSetting(APP_NAME, "Settings", "EmailPassword")
        sendMail.UseAuthentication = True
    End If

    sendMail.Recipient = recipient1
    If Len(recipient2) > 0 Then
        sendMail.Recipient = sendMail.Recipient & ";" & recipient2
    End If
    
    sendMail.Subject = "Error nightly routine"
    sendMail.Message = EmailMessage
    
    sendMail.Send
End Sub

 
Here is what I use:

Add a Reference to Miscrosoft CDO for Windows 2000 Library,
Code:
Public Sub SendAMessage(strFrom As String, strTo As String, _
    strCC As String, strSubject As String, strTextBody As String, _
    Optional strBcc As String)
[green]
'From - e-mail address:     "Joe.Smith@msn.com"
'To - e-mail address(es):   "AndyJ@msn.com;CherylW@msn.com"
'CC - e-mail address(es):   "KimP@msn.com;BarbS@msn.com"
[/green]
Set objMessage = New CDO.Message

With objMessage
    .From = strFrom
    .To = strTo
    If Len(Trim$(strCC)) > 0 Then
        .CC = strCC
    End If
    If Len(strBcc) > 0 Then
        .BCC = strBcc
    End If[green]
    ''' On behalf of
    '.Sender = "CW@msn.com"[/green]
    .Subject = strSubject
    .TextBody = strTextBody
    With .Configuration.Fields
        .Item(CDO.cdoSMTPServer) = "NTSMTP.ABC.ITL.XYZ"
        .Item(CDO.cdoSMTPServerPort) = 25
        .Item(CDO.cdoSendUsingMethod) = CDO.cdoSendUsingPort
        .Item(cdoSMTPConnectionTimeout) = 10
        .Update
    End With
    .Send
End With

Set objMessage = Nothing

End Sub

Tu use it, just pass the parameters

Have fun.

---- Andy
 
Thanks for replying guys!

JoeAtWork,

You are right! I am using a wrong server (my superior gave me a wrong smtp). I manage to make it work now. I will leave the security issues to our net admins since they dont allow us to send on a yahoo address.


Andrzejek,

I'll look into that too, thanks for the info.

Again Thanks guys!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top