From what I remember, the logic responsible for RTE links is in ExpandLinks
processor of renderField
pipeline:
<processor type="Sitecore.Pipelines.RenderField.ExpandLinks, Sitecore.Kernel"/>
public virtual void Process(RenderFieldArgs args)
{
Assert.ArgumentNotNull((object) args, "args");
if (Context.PageMode.IsExperienceEditorEditing)
return;
args.Result.FirstPart = DynamicLink.ExpandLinks(args.Result.FirstPart, Settings.Rendering.SiteResolving);
args.Result.LastPart = DynamicLink.ExpandLinks(args.Result.LastPart, Settings.Rendering.SiteResolving);
}
You could write your own logic here to make sure that links include host name as well.
You can also update LinkProvider
method ExpandDynamicLinks
to force it to include host names:
public virtual string ExpandDynamicLinks(string text, bool resolveSites)
{
Assert.ArgumentNotNull((object) text, "text");
LinkProvider.LinkParser linkParser = this.CreateLinkParser();
UrlOptions defaultUrlOptions = this.GetDefaultUrlOptions();
defaultUrlOptions.SiteResolving = resolveSites;
defaultUrlOptions.AlwaysIncludeServerUrl = true; // <---
return linkParser.ExpandDynamicLinks(text, defaultUrlOptions);
}
EDIT
If you want Sitecore to expand those links for you in custom code, you can run something like that:
protected virtual string RunPipeline(Field field)
{
using (new SiteContextSwitcher(SiteContext.GetSite("website")))
{
RenderFieldArgs renderFieldArgs = new RenderFieldArgs()
{
Item = field.Item,
FieldName = field.Name,
DisableWebEdit = true
};
CorePipeline.Run("renderField", (PipelineArgs) renderFieldArgs);
return renderFieldArgs.Result.FirstPart + renderFieldArgs.Result.LastPart;
}
}
string bodyOfEmail = RunPipeline(item.Fields[FieldIds.EmailBodyField]);