Ok be nice everyone first attempt at anything remotely like this.
Ok I asked Davio if I could take a shot at trying the email function on his mod. Basically I want to continue learning and this seemed like a great way and he was gracious enough to let me.
I would like to know where I have errored in my thinking on this cause I am sure there are many spots lol. Basically I have taken the original code for the emailing a person when their topic is moved and copied it and renamed the function DoAutoMoveEmailMerge and also have done this with the sub for this function. I will post code of this below. In my limited understanding of this and logic it seems like this should email someone if topic is merged.
This is the emailing function in post_info.asp
if MergeTopic then 'not implemented yet
'Send mail to author letting him know his topic was merged with another.
DoAutoMoveEmailMerge(allRec(Topic_ID, intOlderTopic))
strSql = "SELECT M.MEMBER_ID, M.M_NAME, M.M_EMAIL, T.FORUM_ID, T.T_SUBJECT "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS M, " & strActivePrefix & "TOPICS T "
strSql = strSql & " WHERE M.MEMBER_ID = T.T_AUTHOR "
strSql = strSql & " AND T.TOPIC_ID = " & TopicNum
set rs2 = my_Conn.Execute (strSql)
email = rs2("M_EMAIL")
user_name = rs2("M_NAME")
Topic_Title = rs2("T_SUBJECT")
ForumId = rs2("FORUM_ID")
Usernum = rs2("MEMBER_ID")
rs2.close
strRecipientsName = user_name
strRecipients = email
strSubject = strForumTitle & " - Topic Moved"
strMessage = "Hello " & user_name & vbNewLine & vbNewLine
strMessage = strMessage & "Your posting on " & strForumTitle & "." & vbNewLine
strMessage = strMessage & "Regarding the subject - " & Topic_Title & "." & vbNewLine & vbNewLine
if not(chkForumAccess(ForumID,Usernum,false)) then
strMessage = strMessage & "Has been removed from public display. If you have any questions regarding this, please contact the Administrator of the forum" & vbNewLine
else
strMessage = strMessage & "Has been moved to a new forum, You can view it at " & vbNewLine & Left(Request.Form("refer"), InstrRev(Request.Form("refer"), "/")) & "topic.asp?TOPIC_ID=" & TopicNum & vbNewLine
end if
%>
<!--#INCLUDE FILE="inc_mail.asp" -->
<%
end if
'ProcessSubscriptions Reply_Author, Cat_ID, Forum_ID, NewTopicID, Moderation
else
Go_Result "That topic does not exist in the database. Make sure the url you entered has the correct ID of the topic.", 0
end if
'Response.End
Go_Result err_Msg, 1
Response.End
end if
Here is the sub also in post_info.asp
sub DoAutoMoveEmailMerge(TopicNum)
'## Emails Topic Author if Topic Moved.
strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.MEMBER_ID," & strMemberTablePrefix & "MEMBERS.M_NAME, " & strMemberTablePrefix & "MEMBERS.M_EMAIL, " & strActivePrefix & "TOPICS.FORUM_ID, " & strActivePrefix & "TOPICS.T_SUBJECT "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS, " & strActivePrefix & "TOPICS "
strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS.MEMBER_ID = " & strActivePrefix & "TOPICS.T_AUTHOR "
strSql = strSql & " AND " & strActivePrefix & "TOPICS.TOPIC_ID = " & TopicNum
set rs2 = my_Conn.Execute (strSql)
email = rs2("M_EMAIL")
user_name = rs2("M_NAME")
Topic_Title = rs2("T_SUBJECT")
ForumId = rs2("FORUM_ID")
Usernum = rs2("MEMBER_ID")
rs2.close
set rs2 = nothing
if lcase(strEmail) = "1" then
strRecipientsName = user_name
strRecipients = email
strSubject = strForumTitle & " - Topic Moved"
strMessage = "Hello " & user_name & vbNewLine & vbNewLine
strMessage = strMessage & "Your posting on " & strForumTitle & "." & vbNewLine
strMessage = strMessage & "Regarding the subject - " & Topic_Title & "." & vbNewLine & vbNewLine
if not(chkForumAccess(ForumID,Usernum,false)) then
strMessage = strMessage & "Has been removed from public display, If you have any questions regarding this, please contact the Administrator of the forum" & vbNewLine
else
strMessage = strMessage & "Has been moved to a new forum, You can view it at " & vbNewLine & Left(Request.Form("refer"), InstrRev(Request.Form("refer"), "/")) & "topic.asp?TOPIC_ID=" & TopicNum & vbNewLine
end if
%>
<!--#INCLUDE FILE="inc_mail.asp" -->
<%
end if
end sub
If someone could just point me and help me understand this a little better I would greatly appreciate it.
Anyone have a direction to tell me to look at I don't wnat the codeing for this done at all just some ideas where I should look at and see what I can figure out?
Well Basically everything works as it should with the mod but when I try to use the code above and I have tried other vriations the topics get merged but there is supposed to be a email telling the author of the topic that it was merged with another topic. and it gives them the url to their topic.
So everything gets merged but no email is being sent.<
if MergeTopic then
if strEmail = "1" and strMoveNotify = "1" then DoAutoMergeEmail(allRec(Topic_ID, intOlderTopic))
strSQL = "SELECT F_SUBSCRIPTION FROM " & strTablePrefix & "FORUM WHERE FORUM_ID=" & cLng(aryForum(1))
set rs = my_conn.execute (strSQL)
if rs("F_SUBSCRIPTION") < 3 then
strSQL = "DELETE FROM " & strTablePrefix & "SUBSCRIPTIONS WHERE TOPIC_ID=" & Topic_ID
my_conn.execute(strSQL),,adCmdText + adExecuteNoRecords
end if
rs.close
set rs = nothing
end if
That is for the code to call for the sub to send the email and here is the sub code
sub DoAutoMergeEmail(TopicNum)
'## Emails Topic Author if Topic Merged.
strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.MEMBER_ID," & strMemberTablePrefix & "MEMBERS.M_NAME, " & strMemberTablePrefix & "MEMBERS.M_EMAIL, " & strActivePrefix & "TOPICS.FORUM_ID, " & strActivePrefix & "TOPICS.T_SUBJECT "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS, " & strActivePrefix & "TOPICS "
strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS.MEMBER_ID = " & strActivePrefix & "TOPICS.T_AUTHOR "
strSql = strSql & " AND " & strActivePrefix & "TOPICS.TOPIC_ID = " & TopicNum
set rs2 = my_Conn.Execute (strSql)
email = rs2("M_EMAIL")
user_name = rs2("M_NAME")
Topic_Title = rs2("T_SUBJECT")
ForumId = rs2("FORUM_ID")
Usernum = rs2("MEMBER_ID")
rs2.close
set rs2 = nothing
if lcase(strEmail) = "1" then
strRecipientsName = user_name
strRecipients = email
strSubject = strForumTitle & " - Topic Moved"
strMessage = "Hello " & user_name & vbNewLine & vbNewLine
strMessage = strMessage & "Your posting on " & strForumTitle & "." & vbNewLine
strMessage = strMessage & "Regarding the subject - " & Topic_Title & "." & vbNewLine & vbNewLine
if not(chkForumAccess(ForumID,Usernum,false)) then
strMessage = strMessage & "Has been merged with another topic, You can view it at " & vbNewLine & Left(Request.Form("refer"), InstrRev(Request.Form("refer"), "/")) & "topic.asp?TOPIC_ID=" & TopicNum & vbNewLine
end if
%>
<!--#INCLUDE FILE="inc_mail.asp" -->
<%
end if
end sub
I really am just walking through all of this trying to get a understanding of how it works and not sure if I am on the right path or not. <
is it getting to the mail function ? you need to put some response.write checks in your code to ascertain where it is going wrong, it is not possible to say that by just looking at a code sample. for instance is strMoveNotify = "1" etc etc<
Ahh ok I will give that a shot. My thinking on that line was that would refer back to where the code begins for the Merge Topic code. Thanks for the direction Davio and huw.<
OK great I would do it right now but I am at work and for some reason the windows IE ftp program stopped working for me. So I will have to wait till I get home.<