Platform SDK: CDO 1.2.1

ContentLocation Property (CDONTS NewMail Object)

The ContentLocation property sets an absolute or relative path for all URLs relating to the NewMail object's message body. Write-only.

Syntax

objNewMail.ContentLocation 
 

Data Type

String

Remarks

The ContentLocation property is used for MHTML (MIME HTML) support. It represents the Content-Location header for URLs pertaining to the main body of a MIME message. ContentLocation corresponds to the ContentLocation property of a Message object.

If the ContentLocation property is set, it is taken as an absolute or relative URL that can be used to refer to the message body of the NewMail object. If the ContentBase property is also set, ContentLocation is taken as relative and is joined to the base provided by ContentBase.

The Body property of the NewMail object can also contain HTML tags that use URLs, for example <IMG> and <FORM>. If the resource for such a URL is not local to the recipient of the NewMail object, you must provide a path to locate the URL on the Internet. One way to do this is to provide the full path in the URL itself:

 <IMG SRC=HTTP://www.microsoft.com/graphs/Feb1998/21Jul98/today.gif> 
 

It is often more flexible, however, to supply the path externally and put only the resource name in the URL:

 <IMG SRC=today.gif> 
 

When this approach is taken, the ContentLocation and ContentBase properties can be used to supply the path. ContentLocation can contain an absolute path:

  objNewMail.ContentLocation = "HTTP://www.microsoft.com/graphs/Jul1998/21Jul98/" 
 

or a relative path:

  objNewMail.ContentLocation = "Jul1998/21Jul98/" 
 

If ContentLocation contains a relative path, the base URL is supplied in ContentBase:

  objNewMail.ContentBase = "HTTP://www.microsoft.com/graphs/" 
 

When ContentBase and ContentLocation are combined using standard URL combination rules, the result is an absolute path to the resource referenced by the URL.

Often a resource is included as an attachment to the NewMail object. When this is the case, the ContentLocation and ContentBase parameters of the AttachURL method are used to specify the attachment's URL. They are combined the same way the ContentLocation and ContentBase properties are combined. The URL specified by the attachment must match the URL requested by the HTML tag in the Body property, or the tag is not successfully resolved.

The simplest case of attaching with URLs is when your message body refers to the attachments by their ContentLocation parameter values. In this case you do not need either the ContentLocation or the ContentBase property, and the attachments only need resource names in their ContentLocation parameters. This code fragment sends a weekly review of sales activity with two chart images attached:

  Set objNewMail = CreateObject("CDONTS.NewMail") 
  strBody = "<HTML><HEAD></HEAD><BODY>" _ 
          & "This is the sales chart for the past week:" & vbCrLf _ 
          & "<IMG SRC=week.gif>" & vbCrLf _ 
          & "and this is the sales chart for the month:" & vbCrLf _ 
          & "<IMG SRC=month.gif>" & "</BODY></HTML>" 
  objNewMail.AttachURL "\\myserver\sales\pastweek.gif", "week.gif" 
  objNewMail.AttachURL "\\myserver\sales\thismnth.gif", "month.gif" 
  objNewMail.Send "Automated Sales Report", "you@microsoft.com", _ 
                  "Sales Charts", strBody, 0 
  Set objNewMail = Nothing ' canNOT reuse it for another message 
 

Note that the URL string specified in the ContentLocation parameter of the AttachURL method does not have to match the file name of the underlying resource. The only requirement is that it match the URL requested by the HTML tag in the message body.

For more information on MHTML, see the RFC 2110 document.