Hi
I need to send an email with some information inserted on an Form. The body of the emal has to be like this:
ROCHELLE PARK
Date: 07/25/04 Time: 03:12 PM
User: dhenriqu
Tracking Number: A04NHPKOL10002_850_021104
Sites: 1234 1234 1234
Type of Error: HOPP PARAMETERS/ FREQ
Contacted Person: John Smith
Problem Description: This is the problem description
Solution: At the moment of generating this ticket there was no solution
This VBA code is working. It sends the email with the information I need, however, after sending some emails, it stop working. If I close access and open it again the program would start working againg. I think is because the complex way I'm doing the body of the message (BodyText var)
Function SendEmail()
Dim DistributionList As String
Dim SubjectText As String
Dim BodyText As String
Dim TrackingNumberVar As Variant
Dim BSCVar As Variant
Dim SitesVar As Variant
Dim MarketVar As Variant
Dim ErrorCatgVar As Variant
Dim ErrorDescripVar As Variant
Dim DateVar As Variant
Dim TimeVar As Variant
Dim CMEVar As Variant
Dim EditMsg As Variant
Dim ContactText As Variant
On Error Resume Next
CMEVar = Environ("Username")
DateVar = Me.DateText
TimeVar = Me.TimeText
TrackingNumberVar = Me.TNCombo
MarketVar = Me.MarketLabel.Value
SitesVar = Me.SiteCode
ErrorCatgVar = Me.ErrorCategCombo
ErrorDescripVar = Me.ErrorDescrip
EditMsg = Me.EditMsgCheck
If Me.SolutionDescrip = "" Then
SolutionDescripVar = " At the moment of generating this ticket there was no solution"
Else
SolutionDescripVar = Me.SolutionDescrip
End If
If MarketNotified = True Then
ContactText = vbCrLf & " Contacted Person: " &_ Me.ContactNotifed & " by " & Me.MarketNotifiedViaCombo
Else
ContactText = vbCrLf & " Contacted Person: Nobody on_ the market was inform about this problem"
End If
DistributionList = "daniel.smith@hotmail.com"
SubjectText = "SUBJECT"
BodyText = MarketVar & vbCrLf & vbCrLf & "Date:" & DateVar & "Time: " & TimeVar & vbCrLf & "User:" & CMEVar & vbCrLf & vbCrLf & "Tracking Number:" &_ TrackingNumberVar & vbCrLf & "Sites:" & SitesVar & vbCrLf & "Type of Error:" & ErrorCatgVar & ContactText & vbCrLf & vbCrLf & vbCrLf & "Problem Description: " & ErrorDescripVar & vbCrLf & vbCrLf & "Solution:" & SolutionDescripVar
DoCmd.SendObject ,, "DatafillErrorsForm_AWS", , DistributionList, , , SubjectText, BodyText, EditMsg
End Function
Any idea of what could be the problem? Do you know another way of doing this?
Thanx a lot for your help.
Dan
I need to send an email with some information inserted on an Form. The body of the emal has to be like this:
ROCHELLE PARK
Date: 07/25/04 Time: 03:12 PM
User: dhenriqu
Tracking Number: A04NHPKOL10002_850_021104
Sites: 1234 1234 1234
Type of Error: HOPP PARAMETERS/ FREQ
Contacted Person: John Smith
Problem Description: This is the problem description
Solution: At the moment of generating this ticket there was no solution
This VBA code is working. It sends the email with the information I need, however, after sending some emails, it stop working. If I close access and open it again the program would start working againg. I think is because the complex way I'm doing the body of the message (BodyText var)
Function SendEmail()
Dim DistributionList As String
Dim SubjectText As String
Dim BodyText As String
Dim TrackingNumberVar As Variant
Dim BSCVar As Variant
Dim SitesVar As Variant
Dim MarketVar As Variant
Dim ErrorCatgVar As Variant
Dim ErrorDescripVar As Variant
Dim DateVar As Variant
Dim TimeVar As Variant
Dim CMEVar As Variant
Dim EditMsg As Variant
Dim ContactText As Variant
On Error Resume Next
CMEVar = Environ("Username")
DateVar = Me.DateText
TimeVar = Me.TimeText
TrackingNumberVar = Me.TNCombo
MarketVar = Me.MarketLabel.Value
SitesVar = Me.SiteCode
ErrorCatgVar = Me.ErrorCategCombo
ErrorDescripVar = Me.ErrorDescrip
EditMsg = Me.EditMsgCheck
If Me.SolutionDescrip = "" Then
SolutionDescripVar = " At the moment of generating this ticket there was no solution"
Else
SolutionDescripVar = Me.SolutionDescrip
End If
If MarketNotified = True Then
ContactText = vbCrLf & " Contacted Person: " &_ Me.ContactNotifed & " by " & Me.MarketNotifiedViaCombo
Else
ContactText = vbCrLf & " Contacted Person: Nobody on_ the market was inform about this problem"
End If
DistributionList = "daniel.smith@hotmail.com"
SubjectText = "SUBJECT"
BodyText = MarketVar & vbCrLf & vbCrLf & "Date:" & DateVar & "Time: " & TimeVar & vbCrLf & "User:" & CMEVar & vbCrLf & vbCrLf & "Tracking Number:" &_ TrackingNumberVar & vbCrLf & "Sites:" & SitesVar & vbCrLf & "Type of Error:" & ErrorCatgVar & ContactText & vbCrLf & vbCrLf & vbCrLf & "Problem Description: " & ErrorDescripVar & vbCrLf & vbCrLf & "Solution:" & SolutionDescripVar
DoCmd.SendObject ,, "DatafillErrorsForm_AWS", , DistributionList, , , SubjectText, BodyText, EditMsg
End Function
Any idea of what could be the problem? Do you know another way of doing this?
Thanx a lot for your help.
Dan