Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 Emailer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Dave Goldman
New Member

USA
65 Posts

Posted - 31 October 2009 :  16:12:26  Show Profile  Reply with Quote
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

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 01 November 2009 :  03:59:45  Show Profile  Reply with Quote

<%
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]


Edited by - Carefree on 02 November 2009 09:29:59
Go to Top of Page

modifichicci
Average Member

Italy
787 Posts

Posted - 01 November 2009 :  05:20:18  Show Profile  Visit modifichicci's Homepage  Reply with Quote
you need to add a check to see if the mail has been sent to avoid a lot of mail to be sent

Ernia e Laparocele
Forum di Ernia e Laparocele
Acces - MySql Migration Tutorial
Adamantine forum
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 01 November 2009 :  05:37:29  Show Profile  Reply with Quote
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.
Go to Top of Page

Dave Goldman
New Member

USA
65 Posts

Posted - 01 November 2009 :  07:57:55  Show Profile  Reply with Quote
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.
Go to Top of Page

modifichicci
Average Member

Italy
787 Posts

Posted - 01 November 2009 :  08:22:46  Show Profile  Visit modifichicci's Homepage  Reply with Quote
quote:
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..

Ernia e Laparocele
Forum di Ernia e Laparocele
Acces - MySql Migration Tutorial
Adamantine forum
Go to Top of Page

Dave Goldman
New Member

USA
65 Posts

Posted - 01 November 2009 :  09:14:20  Show Profile  Reply with Quote
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?
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 02 November 2009 :  08:35:42  Show Profile  Reply with Quote
quote:
...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.

Edited by - Carefree on 02 November 2009 09:30:30
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000 Version 3.4.07