--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -317,11 +317,11 @@
     return ' '.join(result).replace('\n', '<br/>\n')
 
 def gen_message_id():
-    if c.project:
+    if getattr(c, 'project', None):
         parts = c.project.url().split('/')[1:-1]
     else:
         parts = ['mail']
-    if c.app:
+    if getattr(c, 'app', None):
         addr = '%s.%s' % (nonce(40), c.app.config.options['mount_point'])
     else:
         addr = nonce(40)
@@ -552,4 +552,4 @@
         text = pylons.g.pypeline_markup.render(name, text)
         if not pylons.g.pypeline_markup.can_render(name):
             text = '<pre>%s</pre>' % text
-    return Markup(text)+    return Markup(text)