Click here to Skip to main content
15,900,368 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
Tom Chantler11-Jan-11 21:54
professionalTom Chantler11-Jan-11 21:54 
AnswerRe: [VB.NET 2010] Sending mail only works sometimes Pin
allodoxaphobia11-Jan-11 20:10
allodoxaphobia11-Jan-11 20:10 
AnswerRe: [VB.NET 2010] Sending mail only works sometimes Pin
Lokanta_b11-Jan-11 20:11
Lokanta_b11-Jan-11 20:11 
AnswerRe: [VB.NET 2010] Sending mail only works sometimes Pin
Gareth.pn11-Jan-11 22:31
professionalGareth.pn11-Jan-11 22:31 
AnswerRe: [VB.NET 2010] Sending mail only works sometimes Pin
abhisheksingh15612-Jan-11 0:14
abhisheksingh15612-Jan-11 0:14 
AnswerRe: [VB.NET 2010] Sending mail only works sometimes Pin
TheCodeMonk12-Jan-11 4:59
TheCodeMonk12-Jan-11 4:59 
AnswerRe: [VB.NET 2010] Sending mail only works sometimes Pin
jschell12-Jan-11 8:30
jschell12-Jan-11 8:30 
AnswerRe: [VB.NET 2010] Sending mail only works sometimes Pin
Fred Bakker12-Jan-11 8:49
Fred Bakker12-Jan-11 8:49 
You could something like this:

' This is a action on pushing a button

On Error GoTo Err_Knop40_Click

Dim stDocName As String
Dim stDocOntvanger As String
Dim stDocFrom As String
Dim stDocCC As String
Dim stDocBcc As String
Dim stDocOnderwerp As String
Dim stDocText As String
Dim stDocAfzender As String
Dim Naam As String
Dim I As Integer
Dim strsql As String
Dim EMAIL

Dim rString As String * 255, sLen As Long, tString As String
'
tString = ""
sLen = GetUserName(rString, 255)
sLen = InStr(1, rString, Chr(0))
'
If sLen > 0 Then
'
tString = Left(rString, sLen - 1)
'
Else
'
tString = rString
'
End If

Naam = tString

stDocName = "Empty_Report"
stDocOntvanger = RTrim$(Me.EMAIL-address)
stDocOnderwerp = "Subject....... "

stDocText = "Hello " & RTrim$(Me.name) & " " & IIf(Left$(Me.subname, 1) = " ", "", RTrim$(Me.etc) & " ") & RTrim$(Me.othername) & ","
stDocText = stDocText & vbCrLf & vbCrLf
stDocText = stDocText & "With.........." & vbCrLf
stDocText = stDocText & "....Greetings" & vbCrLf & vbCrLf

stDocAfzender = "Sender......" & vbCrLf & vbCrLf
stDocAfzender = stDocAfzender & ".......Website:" & vbTab & "www........" & vbCrLf



ProviderIp = "192.168.0.0" ' whatever
mailtext = stDocText & stDocAfzender

Set EMAIL = CreateObject("cdo.message")

Foutje = 0
With EMAIL
stdDocFrom = RTrim(Name) & "@........"
EMAIL.from = RTrim(Name) & "@........"
EMAIL.To = stDocOntvanger
EMAIL.CC = ""
EMAIL.BCC = RTrim(BCCName) & "@......" 'For BCC purpose in a different folder
'
EMAIL.Subject = stDocOnderwerp
'
EMAIL.TextBody = mailtext
' Email.AddAttachment "C:\Scripts\Output.txt" ' If you would attachements to it

If MsgBox(mailtext, vbOKCancel, "To: " + stDocOntvanger) = vbCancel Then GoTo Afgebroken_Knop40_Click
I = 20
DoCmd.Hourglass True

EMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
EMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ProviderIp
EMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
EMAIL.Configuration.Fields.Update
EMAIL.Send

DoCmd.Hourglass False

If Foutje = 0 Then
test = MsgBox("The mail is correct send in name of " & Name & " = " & RTrim(Name) & "@..........", vbInformation, vbOKOnly)
End If

End With

Exit_Knop40_Click:
Set EMAIL = Nothing

DoCmd.GoToRecord , , acNext

Exit Sub


Afgebroken_Knop40_Click:
test = MsgBox("The mail is not send in name of " & Name & " = " & RTrim(Name) & "@.........", vbOKOnly)
GoTo Exit_Knop40_Click

Err_Knop40_Click:

Foutje = Err.Number
Select Case Foutje

Case -2147220973
test = MsgBox("No connection with the mailserver." & vbCr & "Errornumber: -2147220973", vbCritical, vbOKOnly)
Case -2147220975
test = MsgBox("Wrong or silly answer from the mailserver." & vbCr & "Errornumber: -2147220975", vbCritical, vbOKOnly)
Case -2147220977
test = MsgBox("Mailaddress doesn't excist." & vbCr & "Errornumber: -2147220977", vbCritical, vbOKOnly)
Case 3075
test = MsgBox("SQL error occurred." & vbCr & "Errornumber: " & Str(Foutje), vbOKOnly)
Case Else
test = MsgBox("Unknown error occurred." & vbCr & "Errornumber: " & Str(Foutje), vbOKOnly)
End Select

Resume Next

.......
Maybe it was some help
AnswerRe: [VB.NET 2010] Sending mail only works sometimes Pin
Vika Dev12-Jan-11 12:17
Vika Dev12-Jan-11 12:17 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
The Mighty Atom12-Jan-11 13:13
The Mighty Atom12-Jan-11 13:13 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
Michel Godfroid12-Jan-11 22:21
Michel Godfroid12-Jan-11 22:21 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
Vika Dev13-Jan-11 3:58
Vika Dev13-Jan-11 3:58 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
The Mighty Atom13-Jan-11 8:30
The Mighty Atom13-Jan-11 8:30 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
Luc Pattyn13-Jan-11 12:22
sitebuilderLuc Pattyn13-Jan-11 12:22 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
The Mighty Atom15-Jan-11 7:54
The Mighty Atom15-Jan-11 7:54 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
shreekar18-Jan-11 5:50
shreekar18-Jan-11 5:50 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
The Mighty Atom19-Jan-11 9:02
The Mighty Atom19-Jan-11 9:02 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
Vika Dev1-Feb-11 16:39
Vika Dev1-Feb-11 16:39 
GeneralRe: [VB.NET 2010] Sending mail only works sometimes Pin
The Mighty Atom2-Feb-11 5:35
The Mighty Atom2-Feb-11 5:35 
QuestionMultiple USB Barcode Scanners Pin
KCDude10-Jan-11 10:41
KCDude10-Jan-11 10:41 
AnswerRe: Multiple USB Barcode Scanners Pin
Luc Pattyn10-Jan-11 11:03
sitebuilderLuc Pattyn10-Jan-11 11:03 
AnswerHIDlibrary Pin
David Mujica11-Jan-11 3:30
David Mujica11-Jan-11 3:30 
GeneralRe: HIDlibrary Pin
Vika Dev12-Jan-11 12:20
Vika Dev12-Jan-11 12:20 
GeneralRe: HIDlibrary - New location at GitHub Pin
David Mujica18-Jan-11 6:18
David Mujica18-Jan-11 6:18 
QuestionMessage Removed Pin
10-Jan-11 8:25
KCDude10-Jan-11 8:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.