Emailer - نوشته شده در (1828 Views)
New Member
Dave Goldman
مطلب: 65
65
Hey guys, I have a fast question. I wrote some code so I can send an email to the user if it is their birthday. I am piggybacking off of another function from a mod and I would like to know the best way to retrieve the users name and email address.
function EmailUserBirthdayNotice

Dim userName, userEmail
' Need to retrieve the data

'## E-mails Message to the Author of this Reply.
strRecipientsName = userName
strRecipients = userEmail
strFrom = "My Forum"
strFromName = strForumTitle
strsubject = "Happy Birthday " & userName & " !"
strMessage = "Hello " & PWMember_Name & vbNewline & vbNewline
strMessage = strMessage & "You received this message from My Forum because today is your birthday. We wanted to wish you a Happy Birthday!" & vbNewline & vbNewline
strMessage = strMessage & vbNewLine & "Have a great birthday!." & vbNewLine & vbNewLine
strMessage = strMessage & vbNewLine & "My Forum" & vbNewLine & vbNewLine
%>
<!--#INCLUDE FILE="inc_mail.asp" -->
<%

end function

Thanks
Dave
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
Code:

<%
Function EmailUserBirthdayNotice
strDOB=mid(strtodate(strForumTimeAdjust),4,4)
strSql="SELECT C_VARIABLE, C_VALUE FROM "& strTablePrefix & "CONFIG_NEW WHERE C_VARIABLE='STRBIRTHMAIL'"
set rsBDay=my_Conn.Execute(strSql)
if not rsBDay.EOF then
strCDOB=rsBDay("C_VALUE")
rsBDay.Close
end if
set rsBDay=Nothing
if strCDOB<>strDOB then
strSql="UPDATE "& strTablePrefix & "CONFIG_NEW SET C_VALUE='" & STRDOB & "' WHERE C_VARIABLE='STRBIRTHMAIL'"
my_Conn.Execute(strSql)
strSql="SELECT M_FIRSTNAME, M_EMAIL, M_DOB FROM " & strMemberTablePrefix & "MEMBERS WHERE MID(M_DOB,4)="&strDOB
set rsDOB=my_Conn.Execute(strSql)
if not rsDOB.EOF then
do until rsDOB.EOF
strRecipientsName = rsDOB("M_FIRSTNAME")
strRecipients = rsDOB("M_EMAIL")
Call SMail
loop
rsDOB.Close
end if
set rsDOB=Nothing

Sub SMail
strFrom = "My Forum"
strFromName = strForumTitle
strsubject = "Happy Birthday " & userName & " !"
strMessage = "Hello " & PWMember_Name & vbNewline & vbNewline
strMessage = strMessage & "You received this message from My Forum because today is your birthday. We wanted to wish you a Happy Birthday!" & vbNewline & vbNewline
strMessage = strMessage & vbNewLine & "Have a great birthday!." & vbNewLine & vbNewLine
strMessage = strMessage & vbNewLine & "My Forum" & vbNewLine & vbNewLine
%>
<!--#INCLUDE FILE="inc_mail.asp" -->
<%
End Sub
end if
End Function
%>

To add the variable to the config_new table, save the following as dbs.BMail and execute from admin control panel. Birthday Mail Mod v1.0
[INSERT] CONFIG_NEW
(C_VARIABLE,C_VALUE)#('strBirthMail',0)
[END]
نوشته شده در
Average Member
modifichicci
مطلب: 787
787
you need to add a check to see if the mail has been sent to avoid a lot of mail to be sent
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
Not if he's going to manually run the program from an admin console page - it'll only send one per person with a birthday on that date. If he embeds it in a commonly accessed page, then you're correct, it would send the emails every time that function was called.
نوشته شده در
New Member
Dave Goldman
مطلب: 65
65
Is there an easy way to check for that? Possibly adding a new field to the database? I think this would be a cool add in. What I did was took an old post that basically checked the birthday by calling two functions isbday and getGreeting. Basically I just wanted to send the email one time if it was the birthday as these two functions just say happy birthday in the header.
نوشته شده در
Average Member
modifichicci
مطلب: 787
787
Not if he's going to manually run the program from an admin console page

not very comfortable... I have implemented the function, but it needs the event mod and the birthday mod, adding a new field M_SENTMAIL to MEMBERS_BDATES table
That is possible as the mod store the dob in that table and delete them after sometimes, so the field is set to 0 again next time..
نوشته شده در
New Member
Dave Goldman
مطلب: 65
65
I do have both mods installed. Do you want me to test it? Do you have the link to the exact event mod just so I can make sure I have the same one as you?
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
...it needs the event mod and the birthday mod, adding a new field M_SENTMAIL to MEMBERS_BDATES table
Not really. All you'd have to do is add a variable to "config.asp", store the date in it when it starts to send EMails. Then when the function is called, check the value of the variable. If it matches the current date, don't send. Done.
I made the appropriate change in above post.
 
شما باید یک متن وارد کنید