Automatic Email (1 Viewer)

Waldin

Registered User.
Local time
Today, 03:41
Joined
Oct 11, 2012
Messages
109
Hi Ladies and Gentleman, my intentions is to send an automatic email every morning at 10 to the suppliers who has outstanding deliveries.

Private Sub Form_Timer()
SetWarnings = True
If TimeValue(Now) > CDate("10:00") Then
Me.TimerInterval = 0
DoCmd.SendObject acSendForm, "WaldinPODetails", acFormatPDF,[List0]![Column1], [track2@magcc.co.za], [], [Reminder Of Parts Not Deleivered], [Good Morning, please recieve this reminder to state that the following parts has not been delivered]

End If
End Sub

the Highlighted text contains errors after I compile it. can anyone perhaps spot the error
 
Last edited:

pr2-eugin

Super Moderator
Local time
Today, 01:41
Joined
Nov 30, 2011
Messages
8,494
Why have you enclosed all the details in []??? You have to enclose the String values in ""..
Code:
DoCmd.SendObject acSendForm, "WaldinPODetails", _ 
              acFormatPDF, 
[List0]![Column1], [COLOR=Red][B]"[/B][/COLOR]track2@magcc.co.za[B][COLOR=Red]"[/COLOR][/B], , _
              [B][COLOR=Red]"[/COLOR][/B]Reminder Of Parts Not Deleivered[COLOR=Red][B]"[/B][/COLOR], _
              [COLOR=Red][B]"[/B][/COLOR]Good Morning, please recieve this reminder to state that the following parts has not been delivered[COLOR=Red][B]"[/B][/COLOR]
 

Waldin

Registered User.
Local time
Today, 03:41
Joined
Oct 11, 2012
Messages
109
hi Eugin

Thanks for your Response, after entering the code the way you suggested i still recieve an error when compiling it
 

pr2-eugin

Super Moderator
Local time
Today, 01:41
Joined
Nov 30, 2011
Messages
8,494
Okay... I think it might be the way you access the data from the Listbox.. Is it multi select? If not try .ItemSelected property.. If it is multiselct true then you have to first convert it into a String of emails.. and assign that string to the To part..
 

pr2-eugin

Super Moderator
Local time
Today, 01:41
Joined
Nov 30, 2011
Messages
8,494
Okay.. Now try the following code.. I have added a For loop that will go through the list looking for selected entries, and add them to tmpTO String, and use that to send the email..
Code:
Private Sub Form_Timer()
    SetWarnings = True
    If TimeValue(Now) > CDate("10:00") Then
        Me.TimerInterval = 0
        
        Dim tmpTO As String
        For Each i In 
[List0].ItemsSelected
            tmpTo = tmpTo & 
[List0].ItemData(i) & ";"
        Next
        tmpTO = Left(tmpTO, Len(tmpTO)-1)
        
        DoCmd.SendObject acSendForm, "WaldinPODetails", _ 
              acFormatPDF, [B]tmpTO[/B], "track2@magcc.co.za", , _
              "Reminder Of Parts Not Deleivered", _
              "Good Morning, please recieve this reminder to state that the following parts has not been delivered"
    End If
End Sub
 

Waldin

Registered User.
Local time
Today, 03:41
Joined
Oct 11, 2012
Messages
109
thanks Eugin

Theres no error once i compile, but the email doesnt send!
 

pr2-eugin

Super Moderator
Local time
Today, 01:41
Joined
Nov 30, 2011
Messages
8,494
What do you exactly mean when you say it doesn't send??

EDIT: If you mean to send it automatically.. Then use EditMessage parameter to False, as a Default True is assumed which means that you have to use the Outlook application.. Just add a False to the end..
Code:
DoCmd.SendObject acSendForm, "WaldinPODetails", _ 
              acFormatPDF, tmpTO, "track2@magcc.co.za", , _
              "Reminder Of Parts Not Deleivered", _
              "Good Morning, please recieve this reminder to state that the following parts has not been delivered", _
               [COLOR=Red][B]False[/B][/COLOR]
 
Last edited:

Waldin

Registered User.
Local time
Today, 03:41
Joined
Oct 11, 2012
Messages
109
i was under the impression your code would instruct Access to send the email automatically without human intervention?
 

Waldin

Registered User.
Local time
Today, 03:41
Joined
Oct 11, 2012
Messages
109
hi Eugin below is my code
Private Sub Form_Timer()
If TimeValue(Now) > CDate("07:00") Then
DoCmd.SendObject
"track2@magcc.co.za"_
End If
End Sub


now this opens outlook but ive tried every way possible that i know but i cannot seem to get the recipients, CC, subject and attachments in its respectfull fields in outlook

please assist me in this.
 

pr2-eugin

Super Moderator
Local time
Today, 01:41
Joined
Nov 30, 2011
Messages
8,494
Well there is not just to field in the DoCmd.Send object there are other fields like CC, BCC followed by the To..
From Microsoft website,
.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)
To add these information just follow them with a comma..
Code:
Private Sub Form_Timer()
     If TimeValue(Now) > CDate("07:00") Then
         DoCmd.SendObject acSendForm, "WaldinPODetails", _ 
             acFormatPDF, [COLOR=Red][B]toaddress@todomain.com[/B][/COLOR], [B][COLOR=Red]ccaddress@ccdomain.com[/COLOR][/B], [COLOR=Red][B]bccaddress@bccdomain.com[/B][/COLOR], _
              "Reminder Of Parts Not Deleivered", _
             "Good Morning, please recieve this reminder to state that the following parts has not been delivered", _
             False
     End If
End Sub
You do not have to worry about attachments as they are send in the first three arguments.. For more information.. visit.. Microsoft website
 

Waldin

Registered User.
Local time
Today, 03:41
Joined
Oct 11, 2012
Messages
109
thanks for your speedy reply Eugin, the above generates a syntax error code
 

pr2-eugin

Super Moderator
Local time
Today, 01:41
Joined
Nov 30, 2011
Messages
8,494
What is the Error number and Error message??
 

Waldin

Registered User.
Local time
Today, 03:41
Joined
Oct 11, 2012
Messages
109
upon compiling it, i get : compile error : syntex error.
 

pr2-eugin

Super Moderator
Local time
Today, 01:41
Joined
Nov 30, 2011
Messages
8,494
Can I see the code you have placed? exactly as it is... Also highlighting which line is the error occurs..
 

Waldin

Registered User.
Local time
Today, 03:41
Joined
Oct 11, 2012
Messages
109
Private Sub Form_Timer()
If TimeValue(Now) > CDate("07:00") Then
DoCmd.SendObject acSendForm, "WaldinPODetails", _
acFormatPDF, support@magcc.co.za,,, _
"Reminder Of Parts Not Deleivered", _
"Good Morning, please recieve this reminder to state that the following parts has not been delivered", _
False
End If
End Sub


i have no cc or bcc addresess to fill
 

pr2-eugin

Super Moderator
Local time
Today, 01:41
Joined
Nov 30, 2011
Messages
8,494
You should surround emails with "" as they are Strings..
Code:
Private Sub Form_Timer()
    If TimeValue(Now) > CDate("07:00") Then
        DoCmd.SendObject acSendForm, "WaldinPODetails", _
            acFormatPDF, [COLOR=Red][B]"[/B][/COLOR]support@magcc.co.za[COLOR=Red][B]"[/B][/COLOR],,, _
            "Reminder Of Parts Not Deleivered", _
            "Good Morning, please recieve this reminder to state that the following parts has not been delivered", _
            False
    End If
End Sub
 

Users who are viewing this thread

Top Bottom