diff --git a/src/sbbs3/getmsg.cpp b/src/sbbs3/getmsg.cpp
index 9ba56172a2cffc420da08e514cc0fc0c5414e71b..63d452d29c875345569e4e66522e3ff83eb706a8 100644
--- a/src/sbbs3/getmsg.cpp
+++ b/src/sbbs3/getmsg.cpp
@@ -323,6 +323,7 @@ void sbbs_t::download_msg_attachments(smb_t* smb, smbmsg_t* msg, bool del)
 			if(!sp) sp=strrchr(tp,'\\');
 			if(sp) tp=sp+1;
 			file_t	fd;
+			fd.dir=cfg.total_dirs+1;			/* temp dir for file attachments */
 			padfname(tp,fd.name);
 			SAFEPRINTF3(fpath,"%sfile/%04u.in/%s"  /* path is path/fname */
 				,cfg.data_dir, msg->idx.to, tp);
diff --git a/src/sbbs3/readmail.cpp b/src/sbbs3/readmail.cpp
index 88804324b3d7f56f7200f02ae1f685e6b7732bc7..7533bff91f3234f5c3ca2a0184408f91520651cc 100644
--- a/src/sbbs3/readmail.cpp
+++ b/src/sbbs3/readmail.cpp
@@ -67,7 +67,6 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode)
     long    l,last_mode;
 	ulong	last;
 	bool	replied;
-	file_t	fd;
 	mail_t	*mail;
 	smbmsg_t msg;
 	char search_str[128] = "";
@@ -89,8 +88,6 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode)
 
 	msg.total_hfields=0;			/* init to NULL, cause not allocated yet */
 
-	fd.dir=cfg.total_dirs+1;			/* temp dir for file attachments */
-
 	if((i=smb_stack(&smb,SMB_STACK_PUSH))!=0) {
 		errormsg(WHERE,ERR_OPEN,"MAIL",i);
 		return;