Free Support Forum -

Using aspose email with Unsubscribe link

Hi I am using aspose email for sending bulk emails. I have implemented unsubscribe hyper link in email body

DirectoryInfo dirInfo = new DirectoryInfo("…/…/ToEmaillist/" + EmailBodyFileName);
Document wordDocument = new Document(dirInfo.FullName);
MemoryStream mhtmlStream = new MemoryStream();
DocumentBuilder builder = new DocumentBuilder(wordDocument);
string UnsubscribeEmail = “” + toemail + “”;
builder.InsertHyperlink(“Click here to Unsubscribe”, UnsubscribeEmail, false);
//builder.InsertHyperlink(“Click here to Unsubscribe”, “ Request.QueryString(‘Email’)”, false);
ArrayList runs = new ArrayList();
Node Separator = null;
foreach (FieldStart fStart in builder.CurrentParagraph.GetChildNodes(NodeType.FieldStart, true))
if (fStart.FieldType == FieldType.FieldHyperlink)
Separator = fStart.GetField().Separator;
Node currentNode = Separator;
while (currentNode.NodeType != NodeType.FieldEnd)
if (currentNode.NodeType == NodeType.Run)
currentNode = currentNode.NextSibling;
foreach (Run run in runs)
Run runNode = new Run(wordDocument);
runNode.Text = “Click here to Unsubscribe”;
runNode.Font.Bold = true;
Separator.ParentNode.InsertAfter(runNode, Separator);
wordDocument.Save(mhtmlStream, SaveFormat.Mhtml);
mhtmlStream.Position = 0;
foreach (string item in SendingEmailList)
Aspose.Email.MailMessage message = Aspose.Email.MailMessage.Load(mhtmlStream, new MhtmlLoadOptions());
if (AttachmentFileName != “Csv” && !string.IsNullOrEmpty(AttachmentFileName))
message.Attachments.Add(new Aspose.Email.Attachment("…/…/ToEmaillist/" + AttachmentFileName));
var body = new StringBuilder();
// body.Append("<a href=‘’> login");
if (!string.IsNullOrEmpty(ccEmail))
message.CC = ccEmail;
if (!string.IsNullOrEmpty(bccEmail))
message.Bcc = bccEmail;
message.From = fromEmail;
message.Subject = subject.ToString();
var client = new Aspose.Email.Clients.Smtp.SmtpClient(smtpserver.ToString());
try { client.Send(message); }

this is my code problem here is unsubscribe link is coming on the top of the email.I need it in the bottom of the email can u help me on this


The code you have shared is not compilable and we are not able to make use of it. Please share with us runnable code and input as well as expected output files for further assistance from our end. We’ll look into it for assisting you further.