UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Vb Script And If Statement To Send Email, 2013    
 
   
red5_tx
post Oct 12 2017, 04:04 PM
Post#1



Posts: 3
Joined: 12-October 17



About Me
Novice VB and Access user
Access 2013
Outlook 2013

Hello everyone. I am requesting help for the following issue. Thank you in advanced for pointing me in the right direction and if I am totally off track please let me know.

I am trying to create an AfterUpdate Event Procedure to do the following:

1. Send email to the same coworkers every time when certain textboxes are null. Example John@work.com, Sam@work.com.
2. Subject of the email to be the value of text boxes “Part” and “Lot”.
3. Body of email to be “Part” and “Lot” along with a generic message like Please Verify.


*****************************************

Private Sub GreenTaggedDate_AfterUpdate()

Dim GreenTaggedDate As String
Dim Family As String
Dim TensileTestDate As String
Dim HEVerificationDate As String
Dim SaltSprayDate As String ' date
Dim ReleaseForceTestDate As String 'date
Dim Part As String 'number
Dim lot As String 'number


If [Family] = "Tongue" And [TensileTestDate] Is Null Then

'code to email here

ElseIf [Family] = "Buckle Base" And [TensileTestDate] Is Null Or [HEVerificationDate] Is Null Then

'code to email here

ElseIf [Family] = "Lockbar" And [TensileTestDate] Is Null Or [SalSprayDate] Is Null Or [ReleaseForceTestDate] Is Null Then

'code to email here

End If


End Sub

*****************************************
Go to the top of the page
 
theDBguy
post Oct 12 2017, 05:18 PM
Post#2


Access Wiki and Forums Moderator
Posts: 71,017
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Welcome to UtterAccess!
welcome2UA.gif

Assuming you meant to use VBA, have you looked into the SendObject method?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
red5_tx
post Oct 13 2017, 12:07 PM
Post#3



Posts: 3
Joined: 12-October 17



Thank you sir for the reply. I have looked into the SendObject Methods and I will try to put some code together over the weekend and repost. Thank you again.
Go to the top of the page
 
theDBguy
post Oct 13 2017, 12:36 PM
Post#4


Access Wiki and Forums Moderator
Posts: 71,017
Joined: 19-June 07
From: SunnySandyEggo


Hi,

You're welcome. Let us know if you run into any issues. Have a good weekend.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
red5_tx
post Oct 16 2017, 09:36 AM
Post#5



Posts: 3
Joined: 12-October 17



Sorry to say but I am not having any luck and I think I might look into trying to do this with a macro. Here is the last code I was playing with. Any help would be appreciated.

Public Function SendEmailWithOutlook( _
MessageTo As String, _
Subject As String, _
MessageBody As String)


Dim olApp As New Outlook.Application
Dim olMailItem As Outlook.MailItem

Set olMailItem = olApp.CreateItem(olMailItem)

With olMailItem
.To = MessageTo
.Subject = Subject
.Body = MessageBody
.Send = bobandbecca727@gmail.com
End With

Set olMailItem = Nothing
Set olApp = Nothing

End Function

Private Sub GreenTaggedDate_AfterUpdate()

Dim GreenTaggedDate As String
Dim Family As String
Dim TensileTestDate As String
Dim HEVerificationDate As String
Dim SaltSprayDate As String
Dim ReleaseForceTestDate As String
Dim Part As String
Dim lot As String


If [Family] = "Tongue" And [TensileTestDate] Is Null Then

Call Function_Name(SendEmailWithOutlook)


ElseIf [Family] = "Buckle Base" And [TensileTestDate] Is Null Or [HEVerificationDate] Is Null Then

Call Function_Name(SendEmailWithOutlook)


ElseIf [Family] = "Lockbar" And [TensileTestDate] Is Null Or [SalSprayDate] Is Null Or [ReleaseForceTestDate] Is Null Then

Call Function_Name(SendEmailWithOutlook)

End If

End Sub
Go to the top of the page
 
theDBguy
post Oct 16 2017, 10:44 AM
Post#6


Access Wiki and Forums Moderator
Posts: 71,017
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Hmm, it doesn't look like you decided to try the SendObject method. Also, what is Function_Name()? Did you create a function to call other functions?

When you say you're not having any luck, exactly what problems are you having? If you're saying you can't even see an email go out, then try a simple command like this, for example:

DoCmd.SendObject acSendNoObject, , , "bobandbecca727@gmail.com", , "THIS IS ONLY A TEST", "Testing 1, 2, 3...", False

Let us know what happens...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    22nd November 2017 - 11:34 AM