• Bernd Nawrath
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 29
    Questions
  • 4
    Replies
hello dear community, I was having trouble sending a PDF to an opportunity, whenever I want to send the PDF files via Adons, Salesforce is telling me the file is not found, even though I have the PDF file saved as a component as well as its apex class which generates the specific contact information on the pdf which is going to be sent. 
The PDF file is also saved as a visualforce page but it seems only to be working as the preview.
Also I wanted to change some things on the component but it doesn't help it because it cannot be sent anyway, so what do I do?
Please have a look on the code maybe there's something wrong:
thanks in advance!

(component aka PDF)
<apex:component controller="MandatPDF" access="global">
<apex:attribute name="accountId" type="string" assignTo="{!actId}" description="to fetch account contacts"/>
<apex:attribute name="opId" type="string" assignTo="{!oppId}" description="to fetch account contacts"/>
        <apex:repeat value="{!AccConOppList}" var="AccCon">

<style type="text/css">
@page {
   size: 210mm 297mm; /* A4 width and height */
    margin:0mm;
    margin-top: 10mm;
    margin-left: 10mm;
    margin-right: 18mm;
    marging-bottom: 5mm;
}
HTML, body, p, {
    margin: 0;
    padding: 0;
    }
    
#pageNum:before {
    content: "Seite " counter(page);
}
.pageNum {
   float: right;
}    
/* div {border: 1px solid #000;} */
.document {
    min-height: 272mm;
    position: relative; 
    font-family: "Sans-Serif";
    font-size: 10pt;
    margin-left: 10mm;
}
.logo {
    margin-right: 5mm;
    margin-left: -5mm;
    float: left;
}
.headline {
    font-size: 19pt;
    margin-top: 9.5mm;
    float: left;
}
.kdref {
    font-size: 8pt;
    padding-top: 10mm;
    text-align: right;
}
.doctype {
    font-size: 16pt;
    margin-top: 10mm;
    margin-bottom: 10mm;
    border-bottom: 1px solid #000;
}

.text {
    text-align: justify;
    font-size: 11pt;
    line-height: 16pt;
}

.footer-right {
    float: right;
    text-align: right;
}

.footer { position:absolute; bottom:0; width:100%;}
.page-break { display:block; page-break-after:always;}
.clearing { clear: both; }
</style>

<!-- ################ Seite 1 ################ -->
<div class="document page-break">
    <div class="logo"><img src="https://c.eu3.content.force.com/servlet/servlet.ImageServer?id=015w0000001JOTq&oid=00Dw0000000Cy2g&lastMod=1411384891000" width="53mm"/></div>
    <div class="headline">Tarifoptimierung für Privatpatienten</div>
    <div class="kdref clearing">Kundenreferenz&nbsp;<apex:outputField value="{!AccCon.Account.Kundennummer_del__c}"/></div>
    <div class="doctype">Bevollmächtigung</div>
    <div class="text">
        <div style="padding-bottom: 10mm;">Hiermit erteile ich&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/>, geboren am&nbsp;<apex:outputField value="{!AccCon.Account.Geburtsdatum__c}"/>, wohnhaft in&nbsp;<apex:outputField value="{!AccCon.Account.PersonMailingCity}"/></div>
        
        <div style="float: left;width: 65mm;"><apex:outputField value="{!AccCon.Account.PersonMailingPostalCode}"/>&nbsp;<apex:outputField value="{!AccCon.Account.PersonMailingCity}"/></div><div style="float: left;width: 65mm;"><apex:outputField value="{!AccCon.Account.PersonMailingStreet}"/></div>
        <div style="float:left;font-size: 7pt; border-top: 1px solid #000; width: 60mm; margin-right: 5mm;">PLZ/Ort</div>
        <div style="float:left;font-size: 7pt; border-top: 1px solid #000; width: 60mm; margin-bottom: 5mm;">Straße</div>
        <div style="float:left; width: 60mm; margin-right: 5mm;">krankenversichert bei der</div>
        <div style="float:left;"><apex:outputText value="{!AccCon.Versicherungsgesellschaft__r.Name}"/></div>
        <div style="float:left; width: 60mm; font-size: 7pt; border-top: 1px solid #000;  margin-right: 20mm; margin-left: 65mm; margin-bottom: 3mm; padding: 0px;">Versicherungsgesellschaft</div>
        
        <div style="float:left; width: 60mm; margin-right: 5mm;">mit Versicherungsnummer</div>
        <div style="float:left;"><apex:outputText value="{!AccCon.Versicherungsscheinnummer__c}"/></div>
        <div style="float:left; width: 60mm; font-size: 7pt; border-top: 1px solid #000;  margin-right: 20mm; margin-left: 65mm; margin-bottom: 3mm; padding: 0px;"></div>
    </div>
    <div class="text clearing" style="padding-top: 1mm;">
        <p>der Mavencare GmbH die ausschließliche Vollmacht, Informationen zu der bestehenden Krankenversicherung des Auftraggebers beim Versicherer einzuholen und meine Interessen gegenüber dem Versicherer zu vertreten.</p>
        <p>Das umfasst unter anderem die Aufforderung an den Versicherer, für die von der Mavencare GmbH recherchierten Tarife, Berechnungen gemäß § 204 VVG vorzunehmen und diese vom Versicherer anzufordern. Des Weiteren ist die Mavencare GmbH bevollmächtigt, die Tarifumstellung im Auftrag des Auftraggebers gegenüber dem Versicherer einzuleiten und abzuwickeln und beim Versicherer Auskunft über den geltenden Tarif einzuholen.</p>
        <p>Sämtliche von der Mavencare GmbH angeforderten Unterlagen, Daten, Auskünfte und Informationen sind umgehend und direkt an die Mavencare GmbH zu übersenden.</p>
    </div>
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: 20mm; padding-top: 3px;">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/></span>
    </div>
    <div class="footer">
        <div style="float: left;font-size: 16pt; line-height: 22pt; margin-bottom: 4mm;">Bitte vorab per Email an<br/>oder per Telefax an</div>
        <div style="font-size: 16pt; line-height: 22pt;" class="footer-right">kontakt@mavencare.de<br/>040 - 1234567</div>
        <div style="border-top: 1px solid #000; padding-top: 4mm; font-size: 8pt;" class="clearing">Bitte Unterlagen im Original auf dem Postweg an:<br/><span style="font-size: 11pt;">Mavencare GmbH, Wittenbergener Weg 90, 22559 Hamburg</span></div>
    </div>
</div>


<!-- ################ Seite 2 ################ -->
<div class="document">
    <div class="logo"><img src="https://c.eu3.content.force.com/servlet/servlet.ImageServer?id=015w0000001JOTq&oid=00Dw0000000Cy2g&lastMod=1411384891000" width="53mm"/></div>
    <div class="headline">Tarifoptimierung für Privatpatienten</div>
    <div class="clearing" align="right" style="font-size: 8pt; padding-top: 10mm;"><span id="pageNum"></span></div>
    <div class="doctype">Dienstleistungsvertrag</div>
    <div class="text">
        <p>zwischen dem Kunden&nbsp;<apex:outputField value="{!AccCon.Account.Salutation}"/>&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/> und der Mavencare GmbH.</p>
        <p>Die Mavencare GmbH ist vom Kunden beauftragt, die Möglichkeit eines Tarifwechsels innerhalb der Krankenversicherungsgesellschaft des Kunden zu prüfen. Mavencare recherchiert im Namen des Kunden nach Einsparungsmöglichkeiten.</p>
        <p>Erst wenn sich der Kunde entschließt, eine der durch die Mavencare GmbH recherchierten Einsparungsmöglichkeiten durch Tarifumstellung in Auftrag zu geben, wird eine Vergütung der Dienstleistung berechnet. Die Vergütung wird fällig mit der Tarifumstellung. Die Höhe der Vergütung bemisst sich an der monatlichen Ersparnis. Die Differenz zwischen der alten und neuen Monatsprämie multipliziert mit dem Faktor&nbsp;<apex:outputField value="{!AccCon.MC_Faktor__c}"/> ergibt die Gesamtvergütung zuzüglich der gesetzlichen Mehrwertsteuer. Es kann vereinbart werden, dass die Vergütung in acht gleichen Monatsraten gezahlt wird.</P>
        <p>Sollte der Kunde keine der durch die Mavencare GmbH recherchierten Tarifumstellungen nutzen, ist die Dienstleistung der Mavencare GmbH kostenfrei.</p>
        <p>Der Kunde hat mit diesem Schreiben die geltenden Allgemeinen Geschäftsbedingungen, Datenschutzerklärung und Widerrufsbelehrung erhalten, zur Kenntnis genommen und anerkannt.</p>
    </div>
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: 20mm; padding-top: 0px;">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/></span>
    </div>

    <div style="padding-left: 100mm; padding-top: 10mm;">
        <img src="https://c.eu3.content.force.com/servlet/servlet.FileDownload?file=015w0000001JOj0" width="80mm"/>
    </div>     
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: -13mm; ">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift Werner Gerdts / Mavencare GmbH</span>
    </div>
    <div style="padding-left: 10mm; margin-top: -8mm; ">Hamburg, den&nbsp;<apex:outputText value=" {!TODAY()}" /></div>

    <div class="footer">
        <div style="float: left;font-size: 16pt; line-height: 22pt; margin-bottom: 4mm;">Bitte vorab per Email an<br/>oder per Telefax an</div>
        <div style="font-size: 16pt; line-height: 22pt;" class="footer-right">kontakt@mavencare.de<br/>040 - 1234567</div>
        <div style="border-top: 1px solid #000; padding-top: 4mm; font-size: 8pt;" class="clearing">Bitte Unterlagen im Original auf dem Postweg an:<br/><span style="font-size: 11pt;">Mavencare GmbH, Wittenbergener Weg 90, 22559 Hamburg</span></div>
    </div>
</div>

</apex:repeat>
</apex:component>


(apex class)
public class MandatPDF {

// This ID is set by a parameter in the email template
public String actId{get;set;}
public String oppId{get;set;}
//public string Faktor{get;set;}
    // Datum für PDF vorbereiten
    public String getIPDatum()
    {
        Date tmpDatum   =   Date.today();
        system.debug('### ' + tmpDatum + 'Date as String: ' + string.valueOf(tmpDatum));
        
        // return Date as String
        return string.valueOf(tmpDatum);
        
    }

    // Account Informationen sammeln
    public List<Opportunity> getAccConOppList()
    {
        // Wenn die Seite als Vorschau geöffnet wird, kommt die ID als Id Parameter
        if(ApexPages.currentPage().getParameters().get('id')!='' && ApexPages.currentPage().getParameters().get('id').startsWith('001'))
        {
            actId = ApexPages.currentPage().getParameters().get('id');
        }

         // When page is seen as preview, ID appears as ID parameter 
        if(ApexPages.currentPage().getParameters().get('opId')!='' && ApexPages.currentPage().getParameters().get('opId').startsWith('006'))
        {
            oppId = ApexPages.currentPage().getParameters().get('opId');
        }       
        
        system.debug('### actId:' +actId);
        system.debug('### oppId:' +oppId);
        
        return [SELECT MC_Faktor__c, Account.Id, Account.Owner.Name, Account.Owner.Phone, Account.Name, Account.Salutation, Account.Geburtsdatum__c, Account.PersonEmail, Account.textliche_Ansprache__pc, Account.Kundennummer_del__c, Account.akademischer_Titel__pc,Account.PersonMailingStreet, Account.PersonMailingCity, Account.PersonMailingPostalCode, Account.Owner.Benutzer_Unterschriften_URL__c, Account.Owner.Durchwahl__c, Account.doc_salutation__c, Account.doc_academictitle__c, Account.doc_firstname__c, Account.doc_lastname__c, Account.doc_street__c, Account.doc_birthdate__c, Account.doc_zipcode__c, Account.doc_city__c, Account.doc_salutationtext__c, Versicherungsgesellschaft__r.Name, Versicherungsscheinnummer__c FROM Opportunity WHERE Id=:oppId];
        //return [SELECT Id, Owner.Name, Owner.Phone, Name, Salutation, Geburtsdatum__c, PersonEmail, textliche_Ansprache__pc, Kundennummer_del__c, akademischer_Titel__pc,PersonMailingStreet, PersonMailingCity, PersonMailingPostalCode, Owner.Benutzer_Unterschriften_URL__c, Owner.Durchwahl__c, doc_salutation__c, doc_academictitle__c, doc_firstname__c, doc_lastname__c, doc_street__c, doc_birthdate__c, doc_zipcode__c, doc_city__c, doc_salutationtext__c FROM Account WHERE Id = :actId LIMIT 1];
    }

}
hello dear community, I was having trouble sending a PDF to an opportunity, whenever I want to send the PDF files via Adons, Salesforce is telling me the file is not found, even though I have the PDF file saved as a component as well as its apex class which generates the specific contact information on the pdf which is going to be sent.
Also I wanted to change some things on the component but it doesn't help it because it cannot be sent anyway so what do I do?
Have a look on the code maybe there's something wrong:
thanks in advance!

(component aka PDF)
<apex:component controller="MandatPDF" access="global">
<apex:attribute name="accountId" type="string" assignTo="{!actId}" description="to fetch account contacts"/>
<apex:attribute name="opId" type="string" assignTo="{!oppId}" description="to fetch account contacts"/>
        <apex:repeat value="{!AccConOppList}" var="AccCon">

<style type="text/css">
@page {
   size: 210mm 297mm; /* A4 width and height */
    margin:0mm;
    margin-top: 10mm;
    margin-left: 10mm;
    margin-right: 18mm;
    marging-bottom: 5mm;
}
HTML, body, p, {
    margin: 0;
    padding: 0;
    }
    
#pageNum:before {
    content: "Seite " counter(page);
}
.pageNum {
   float: right;
}    
/* div {border: 1px solid #000;} */
.document {
    min-height: 272mm;
    position: relative; 
    font-family: "Sans-Serif";
    font-size: 10pt;
    margin-left: 10mm;
}
.logo {
    margin-right: 5mm;
    margin-left: -5mm;
    float: left;
}
.headline {
    font-size: 19pt;
    margin-top: 9.5mm;
    float: left;
}
.kdref {
    font-size: 8pt;
    padding-top: 10mm;
    text-align: right;
}
.doctype {
    font-size: 16pt;
    margin-top: 10mm;
    margin-bottom: 10mm;
    border-bottom: 1px solid #000;
}

.text {
    text-align: justify;
    font-size: 11pt;
    line-height: 16pt;
}

.footer-right {
    float: right;
    text-align: right;
}

.footer { position:absolute; bottom:0; width:100%;}
.page-break { display:block; page-break-after:always;}
.clearing { clear: both; }
</style>

<!-- ################ Seite 1 ################ -->
<div class="document page-break">
    <div class="logo"><img src="https://c.eu3.content.force.com/servlet/servlet.ImageServer?id=015w0000001JOTq&oid=00Dw0000000Cy2g&lastMod=1411384891000" width="53mm"/></div>
    <div class="headline">Tarifoptimierung für Privatpatienten</div>
    <div class="kdref clearing">Kundenreferenz&nbsp;<apex:outputField value="{!AccCon.Account.Kundennummer_del__c}"/></div>
    <div class="doctype">Bevollmächtigung</div>
    <div class="text">
        <div style="padding-bottom: 10mm;">Hiermit erteile ich&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/>, geboren am&nbsp;<apex:outputField value="{!AccCon.Account.Geburtsdatum__c}"/>, wohnhaft in&nbsp;<apex:outputField value="{!AccCon.Account.PersonMailingCity}"/></div>
        
        <div style="float: left;width: 65mm;"><apex:outputField value="{!AccCon.Account.PersonMailingPostalCode}"/>&nbsp;<apex:outputField value="{!AccCon.Account.PersonMailingCity}"/></div><div style="float: left;width: 65mm;"><apex:outputField value="{!AccCon.Account.PersonMailingStreet}"/></div>
        <div style="float:left;font-size: 7pt; border-top: 1px solid #000; width: 60mm; margin-right: 5mm;">PLZ/Ort</div>
        <div style="float:left;font-size: 7pt; border-top: 1px solid #000; width: 60mm; margin-bottom: 5mm;">Straße</div>
        <div style="float:left; width: 60mm; margin-right: 5mm;">krankenversichert bei der</div>
        <div style="float:left;"><apex:outputText value="{!AccCon.Versicherungsgesellschaft__r.Name}"/></div>
        <div style="float:left; width: 60mm; font-size: 7pt; border-top: 1px solid #000;  margin-right: 20mm; margin-left: 65mm; margin-bottom: 3mm; padding: 0px;">Versicherungsgesellschaft</div>
        
        <div style="float:left; width: 60mm; margin-right: 5mm;">mit Versicherungsnummer</div>
        <div style="float:left;"><apex:outputText value="{!AccCon.Versicherungsscheinnummer__c}"/></div>
        <div style="float:left; width: 60mm; font-size: 7pt; border-top: 1px solid #000;  margin-right: 20mm; margin-left: 65mm; margin-bottom: 3mm; padding: 0px;"></div>
    </div>
    <div class="text clearing" style="padding-top: 1mm;">
        <p>der Mavencare GmbH die ausschließliche Vollmacht, Informationen zu der bestehenden Krankenversicherung des Auftraggebers beim Versicherer einzuholen und meine Interessen gegenüber dem Versicherer zu vertreten.</p>
        <p>Das umfasst unter anderem die Aufforderung an den Versicherer, für die von der Mavencare GmbH recherchierten Tarife, Berechnungen gemäß § 204 VVG vorzunehmen und diese vom Versicherer anzufordern. Des Weiteren ist die Mavencare GmbH bevollmächtigt, die Tarifumstellung im Auftrag des Auftraggebers gegenüber dem Versicherer einzuleiten und abzuwickeln und beim Versicherer Auskunft über den geltenden Tarif einzuholen.</p>
        <p>Sämtliche von der Mavencare GmbH angeforderten Unterlagen, Daten, Auskünfte und Informationen sind umgehend und direkt an die Mavencare GmbH zu übersenden.</p>
    </div>
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: 20mm; padding-top: 3px;">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/></span>
    </div>
    <div class="footer">
        <div style="float: left;font-size: 16pt; line-height: 22pt; margin-bottom: 4mm;">Bitte vorab per Email an<br/>oder per Telefax an</div>
        <div style="font-size: 16pt; line-height: 22pt;" class="footer-right">kontakt@mavencare.de<br/>040 - 1234567</div>
        <div style="border-top: 1px solid #000; padding-top: 4mm; font-size: 8pt;" class="clearing">Bitte Unterlagen im Original auf dem Postweg an:<br/><span style="font-size: 11pt;">Mavencare GmbH, Wittenbergener Weg 90, 22559 Hamburg</span></div>
    </div>
</div>


<!-- ################ Seite 2 ################ -->
<div class="document">
    <div class="logo"><img src="https://c.eu3.content.force.com/servlet/servlet.ImageServer?id=015w0000001JOTq&oid=00Dw0000000Cy2g&lastMod=1411384891000" width="53mm"/></div>
    <div class="headline">Tarifoptimierung für Privatpatienten</div>
    <div class="clearing" align="right" style="font-size: 8pt; padding-top: 10mm;"><span id="pageNum"></span></div>
    <div class="doctype">Dienstleistungsvertrag</div>
    <div class="text">
        <p>zwischen dem Kunden&nbsp;<apex:outputField value="{!AccCon.Account.Salutation}"/>&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/> und der Mavencare GmbH.</p>
        <p>Die Mavencare GmbH ist vom Kunden beauftragt, die Möglichkeit eines Tarifwechsels innerhalb der Krankenversicherungsgesellschaft des Kunden zu prüfen. Mavencare recherchiert im Namen des Kunden nach Einsparungsmöglichkeiten.</p>
        <p>Erst wenn sich der Kunde entschließt, eine der durch die Mavencare GmbH recherchierten Einsparungsmöglichkeiten durch Tarifumstellung in Auftrag zu geben, wird eine Vergütung der Dienstleistung berechnet. Die Vergütung wird fällig mit der Tarifumstellung. Die Höhe der Vergütung bemisst sich an der monatlichen Ersparnis. Die Differenz zwischen der alten und neuen Monatsprämie multipliziert mit dem Faktor&nbsp;<apex:outputField value="{!AccCon.MC_Faktor__c}"/> ergibt die Gesamtvergütung zuzüglich der gesetzlichen Mehrwertsteuer. Es kann vereinbart werden, dass die Vergütung in acht gleichen Monatsraten gezahlt wird.</P>
        <p>Sollte der Kunde keine der durch die Mavencare GmbH recherchierten Tarifumstellungen nutzen, ist die Dienstleistung der Mavencare GmbH kostenfrei.</p>
        <p>Der Kunde hat mit diesem Schreiben die geltenden Allgemeinen Geschäftsbedingungen, Datenschutzerklärung und Widerrufsbelehrung erhalten, zur Kenntnis genommen und anerkannt.</p>
    </div>
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: 20mm; padding-top: 0px;">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/></span>
    </div>

    <div style="padding-left: 100mm; padding-top: 10mm;">
        <img src="https://c.eu3.content.force.com/servlet/servlet.FileDownload?file=015w0000001JOj0" width="80mm"/>
    </div>     
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: -13mm; ">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift Werner Gerdts / Mavencare GmbH</span>
    </div>
    <div style="padding-left: 10mm; margin-top: -8mm; ">Hamburg, den&nbsp;<apex:outputText value=" {!TODAY()}" /></div>

    <div class="footer">
        <div style="float: left;font-size: 16pt; line-height: 22pt; margin-bottom: 4mm;">Bitte vorab per Email an<br/>oder per Telefax an</div>
        <div style="font-size: 16pt; line-height: 22pt;" class="footer-right">kontakt@mavencare.de<br/>040 - 1234567</div>
        <div style="border-top: 1px solid #000; padding-top: 4mm; font-size: 8pt;" class="clearing">Bitte Unterlagen im Original auf dem Postweg an:<br/><span style="font-size: 11pt;">Mavencare GmbH, Wittenbergener Weg 90, 22559 Hamburg</span></div>
    </div>
</div>

</apex:repeat>
</apex:component>


(apex class)
public class MandatPDF {

// This ID is set by a parameter in the email template
public String actId{get;set;}
public String oppId{get;set;}
//public string Faktor{get;set;}
    // Datum für PDF vorbereiten
    public String getIPDatum()
    {
        Date tmpDatum   =   Date.today();
        system.debug('### ' + tmpDatum + 'Date as String: ' + string.valueOf(tmpDatum));
        
        // return Date as String
        return string.valueOf(tmpDatum);
        
    }

    // Account Informationen sammeln
    public List<Opportunity> getAccConOppList()
    {
        // Wenn die Seite als Vorschau geöffnet wird, kommt die ID als Id Parameter
        if(ApexPages.currentPage().getParameters().get('id')!='' && ApexPages.currentPage().getParameters().get('id').startsWith('001'))
        {
            actId = ApexPages.currentPage().getParameters().get('id');
        }

         // When page is seen as preview, ID appears as ID parameter 
        if(ApexPages.currentPage().getParameters().get('opId')!='' && ApexPages.currentPage().getParameters().get('opId').startsWith('006'))
        {
            oppId = ApexPages.currentPage().getParameters().get('opId');
        }       
        
        system.debug('### actId:' +actId);
        system.debug('### oppId:' +oppId);
        
        return [SELECT MC_Faktor__c, Account.Id, Account.Owner.Name, Account.Owner.Phone, Account.Name, Account.Salutation, Account.Geburtsdatum__c, Account.PersonEmail, Account.textliche_Ansprache__pc, Account.Kundennummer_del__c, Account.akademischer_Titel__pc,Account.PersonMailingStreet, Account.PersonMailingCity, Account.PersonMailingPostalCode, Account.Owner.Benutzer_Unterschriften_URL__c, Account.Owner.Durchwahl__c, Account.doc_salutation__c, Account.doc_academictitle__c, Account.doc_firstname__c, Account.doc_lastname__c, Account.doc_street__c, Account.doc_birthdate__c, Account.doc_zipcode__c, Account.doc_city__c, Account.doc_salutationtext__c, Versicherungsgesellschaft__r.Name, Versicherungsscheinnummer__c FROM Opportunity WHERE Id=:oppId];
        //return [SELECT Id, Owner.Name, Owner.Phone, Name, Salutation, Geburtsdatum__c, PersonEmail, textliche_Ansprache__pc, Kundennummer_del__c, akademischer_Titel__pc,PersonMailingStreet, PersonMailingCity, PersonMailingPostalCode, Owner.Benutzer_Unterschriften_URL__c, Owner.Durchwahl__c, doc_salutation__c, doc_academictitle__c, doc_firstname__c, doc_lastname__c, doc_street__c, doc_birthdate__c, doc_zipcode__c, doc_city__c, doc_salutationtext__c FROM Account WHERE Id = :actId LIMIT 1];
    }

}
Hello dear community, I was building an email trigger that basically sends a PDF to a specific contact when this person is added to accounts. 

Now in addition, I deleted the old PDF from the production which needed some changes and uploaded a new PDF as a component which is going to be sent to the contact but for some reason I can still see the preview of the old pdf (which I deleted) when I want to contact a person.

Also I still have the same apex class which generates the specific contact information on this special pdf which is going to be send, but I already changed the component which is referenced to the class so how is this possible that I still see the old pdf in the preview? Do I need to delete something?
I already deployed the code for the email trigger which seemed to be alright but I still can't get it to work so I believe this might be the reason why.
Please help !

thanks in advance :)
hello dear community, I was going to delete apex classes by installing the force.com ide in eclipse for this purpose but since I installed force.com it's not visible in window->show view->other.. 
might this have something to do with the JDK I'm using? I use kempler and so far everythings updated. 
any suggestions? thanks in advance!
Hello dear community, I was wondering how exactly to delete an apex class because obviously you can't do that in the production area, I already tried deleting it from my sandbox which worked but it didnt have any impact on my actual production area.
Thanks in advance
Hello dear community, I just want to make sure my code looks good to go. Basically I created an email trigger that I want to upload into the production now.
Its purpose is: When a new account is added, an email template with pdf attachment is supposed to be sent automatically to that person. Please have a look on the code and tell if you think that's going to do it because I couldnt test it in sandbox, just made sure it works with the test class:
Thanks a lot :)

(main class)
public class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name= 'MCM'];

        system.debug(et);   //debug to check the template

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){

            //check for Account
            if(con.PersonEmail != '' && con.PersonEmail != null) {

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }

        //send mail
        Messaging.sendEmail(emails);

        return accounts;
    }
}

(test class)
@isTest(SeeAllData=true)
private class HelperContactTriggerTestneu {
public static testMethod void myTestMethod() {

 
        system.debug('### NewAccountTest ###');
        Account acc = new Account(Name = 'Test Test');
      
        {
        insert acc;

        List<Account> sendMail = [select id,PersonEmail from account where (Name='Test Test') and id=:acc.id];
        
        
        test.startTest();

        HelperContactTrigger.sendEmail(sendMail);
        test.stopTest();
        System.assert(acc !=null);
        }
        }
        }

(trigger)
trigger MailAusloeser on Account (after insert) {
 
 if(Trigger.isAfter){
        if(Trigger.isInsert ){ 
            //helper class for single email but bulk messages
            HelperContactTrigger.sendEmail(trigger.new);
        }
    }
}

 
good evening dear community,I created an email template for a pdf that is supposed to be sent whenever a new account is added. I just want make sure my code looks good.
I'd be happy if you had any advices.

<messaging:emailTemplate subject="Mandat" recipientType="Contact" relatedToType="Account">
<messaging:plainTextEmailBody >
Dear customer....
</messaging:plainTextEmailBody>
<messaging:attachment renderAs="PDF"> <!-- Use the renderAs attribute here.-->
    <c:NeuesMandat ></c:NeuesMandat><!--gives the reference of the component-->
</messaging:attachment>
</messaging:emailTemplate>

thanks in advance:)
hello dear community,I want to attach a PDF (visualforce component) to an email template which is going to be sent. The email issupposed to be sent to a new account when this account is added. What would the template look like and how do I attach this file to the email template?

thanks in advance! :)
Good evening dear community, I was programming an email trigger that sends a template attached with a pdf autimatically when a new account is added. I have a main class, a test class, the trigger and an email template to test it so far but when I am running the test class to check if it works I get this exception:

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Account.PersonEmail
Class.HelperContactTrigger.sendEmail
Class.HelperContactTriggerTestneu.myTestMethod


What can I do ? If you need more information please let me know because this very important to me. 

This is the code:
(Main class)
public class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name= 'MCM'];

        system.debug(et);   //debug to check the template

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){

            //check for Account
            if(con.PersonEmail == null && con.PersonEmail != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }

        //send mail
        Messaging.sendEmail(emails);

        return accounts;
    }
}

(Test class)
@isTest(SeeAllData=true)
private class HelperContactTriggerTestneu {
public static testMethod void myTestMethod() {

        system.debug('### NewAccountTest ###');
        Account acc = new Account(Name = 'Test Test');
      
        {
        insert acc;

        List<Account> sendMail = [select id from account where (Name='Test Test') and id=:acc.id];
        test.startTest();
        HelperContactTrigger.sendEmail(sendMail);
        test.stopTest();
        System.assert(acc !=null);
        }
        }
        }


Thanks in advance ! :)
Hello dear community, I have a PDF as a visualforce-component and I want this to be sent automatically as an attachment by a trigger when a new account is added. Any advices ?

Thanks in advance ! :)
Hello dear community, I need some help programming an email trigger for my production, I already have a PDF as a visualforce-component and I want this to be sent automatically when a new account is added. Any advices ?

Thanks in advance :) 
Hello dear community, I need some help programming an email trigger for my production, I already have a PDF as a component and I want this PDF to be sent automatically when a new account is added. Any advices on how to make a code to work for this purpose?

Thanks in advance :) 
Hello dear community, I already have an email template as a component and I just want to create a little bit of code, that sends this email to the account when he/she is added, any tipps or advices? thanks in advance:)

hello community, when I was executing with a debug to check on my class this occured:

User-added image

that's the code for the class:

public class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name= 'Sales: New Customer Email' limit 1];

        system.debug(et);   //debug to check the template

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){

            //check for Account
            if(con.PersonEmail == null && con.PersonEmail != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }

        //send mail
        Messaging.sendEmail(emails);
        return accounts;
    }
}

What do I do? I checked the code and everything a million times.
I was having difficulties running a test class for this programm (System.QueryException: List has no rows for assignment to SObject)
so I have to check if the query statement really does what it's supposed to, it has to work as a mailtrigger when a new account is added but the query is having issues so I have to know what the real problem is.

This is the test class:

@isTest
private class HelperContactTriggerTestneuer {
public static testMethod void myTestMethod() {

        Account acc = new Account(Name = 'Test Test');
        insert acc;

        List<Account> sendMail = [select id from account where (Name='Test Test') and id=:acc.id];
   EmailTemplate testTemplate=new EmailTemplate(Name='Neuer Kunde',DeveloperName='Neuer_Kunde',FolderId=Userinfo.getUserId());
   insert testTemplate;

        HelperContactTrigger.sendEmail(sendMail);
        System.assert(acc !=null);
        
        }
        }


thanks in advance :)

Hello dear community, I was trying to create a class with a trigger so send mails autimatically when a new account is inserted. I'm getting this exception for a query that I have in my class as well as in my test class when I'm trying to run the test class: 

myTestMethod
System.QueryException: List has no rows for assignment to SObject
Class.HelperContactTrigger.sendEmail: line 6, column 1 
Class.HelperContactTriggerTestneu.myTestMethod: line 17, column 1

I know it seems like there are no records found that should be returned. So how exactly is my debug statement supposed to look like to check if the account is really inserted?

These are the classes:

public with sharing class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object, is this correct,what might have been the mistake when I'm refering to EmailTemplate?
        EmailTemplate et=[Select id from EmailTemplate where name= 'Sales: New Customer Email' limit 1];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){
        .............
        //send mail
        Messaging.sendEmail(emails);

        return accounts;
    }
}

@isTest(SeeAllData=true)
private class HelperContactTriggerTestneu {
public static testMethod void myTestMethod() {

        system.debug('### NewAccountTest ###');
        Account acc = new Account(Name = 'Test Test');
        {
        insert acc;
                        // Here I'm refering to the test account that I have in my accounts
        List<Account> sendMail = [select id from account where (Name='Test Test') and id=:acc.id];
        
        test.startTest();

        HelperContactTrigger.sendEmail(sendMail);
        test.stopTest();
        System.assert(acc !=null);
        }
        }
        }

thanks in advance! :)
Hello dear community, I was trying to create a class with a trigger so send mails autimatically when a new account is inserted. I'm getting this exception for a query that I have in my class as well as in my test class when I'm trying to run the test class: 
myTestMethod
System.QueryException: List has no rows for assignment to SObject
Class.HelperContactTrigger.sendEmail: line 6, column 1 
Class.HelperContactTriggerTestneu.myTestMethod: line 17, column 1

I know it seems like there are no records found that should be returned. So how exactly is my debug statement supposed to look like to check if the account is really inserted?

These are the classes:

public with sharing class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object, is this correct,what might have been the mistake when I'm refering to EmailTemplate?
        EmailTemplate et=[Select id from EmailTemplate where name= 'Sales: New Customer Email' limit 1];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){
        .............
        //send mail
        Messaging.sendEmail(emails);

        return accounts;
    }
}

@isTest(SeeAllData=true)
private class HelperContactTriggerTestneu {
public static testMethod void myTestMethod() {

        system.debug('### NewAccountTest ###');
        Account acc = new Account(Name = 'Test Test');
        {
        insert acc;
                        // Here I'm refering to the test account that I have in my accounts
        List<Account> sendMail = [select id from account where (Name='Test Test') and id=:acc.id];
        
        test.startTest();

        HelperContactTrigger.sendEmail(sendMail);
        test.stopTest();
        System.assert(acc !=null);
        }
        }
        }

thanks in advance! :)
Hello dear community, I'm getting this exception for a query that I have in my class as well as in my test class when I'm trying to run the test class, how can I fix it? : 
myTestMethod
System.QueryException: List has no rows for assignment to SObject
<span unselectable="on" "="" style="font-weight: normal; display: block; padding: 3px 4px; overflow: hidden; margin-left: 0px;">Class.HelperContactTrigger.sendEmail: line 6, column 1 
Class.HelperContactTriggerTestneu.myTestMethod: line 17, column 1


the classes:

public with sharing class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object, is this correct,what might have been the mistake when I'm refering to EmailTemplate?
        EmailTemplate et=[Select id from EmailTemplate where name= 'Sales: New Customer Email' limit 1];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){
        .............
        //send mail
        Messaging.sendEmail(emails);

        return accounts;
    }
}

@isTest(SeeAllData=true)
private class HelperContactTriggerTestneu {
public static testMethod void myTestMethod() {

        system.debug('### NewAccountTest ###');
        Account acc = new Account(Name = 'Test Test');
        {
        insert acc;
                        // Here I'm refering to the test account that I have in my accounts, still this does not seem to work, how is that possible?
        List<Account> sendMail = [select id from account where (Name='Test Test') and id=:acc.id];
        
        test.startTest();

        HelperContactTrigger.sendEmail(sendMail);
        test.stopTest();
        System.assert(acc !=null);
        }
        }
        }

thanks in advance! :)
Hello dear community, I'm having a very difficult time getting this test class working, whenever I try executing it no matter what I did it's giving me this error: System.QueryException: List has no rows for assignment to SObject. 
I already looked up in my account for the test name which is mentioned in the query, I found it but it still since I get this error it doesn't seem to return anything. When I look up in account, under accountname,am I supposed to pick the name for my test there and use it in my test code or what else do I need to put in exactly?
Please have a look on the classes:

@isTest(SeeAllData=true)
private class HelperContactTriggerTestneu {
public static testMethod void myTestMethod() {

        Account acc = new Account(Name = 'Test Test');
      
        {
        insert acc;

        List<Account> sendMail = [select id from account where (Name='Test Test') and id=:acc.id];
        
        test.startTest();

        HelperContactTrigger.sendEmail(sendMail);
        test.stopTest();
        System.assert(acc !=null);
        }
        }
        }
________________________________________________
public with sharing class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name='Neuer Kunde'];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){

            //check for Account
            if(con.PersonEmail == null && con.PersonEmail != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }
        //send mail
        Messaging.sendEmail(emails);

        return accounts;
    }
}

Thanks in advance :)
Hello dear community, I'm having a very difficult time getting this test class working, whenever I try executing it no matter what I tried it's giving me this error: System.QueryException: List has no rows for assignment to SObject. 
I already looked up in my account for the test name which is mentioned in the query, I found it but it still since I get this error it doesn't seem to return anything, when I look up in account, under accountname,am I supposed to pick the name for my test there and use it in my test code or what else do I need to put in exactly?
Please have a look on the classes:

@isTest(SeeAllData=true)
private class HelperContactTriggerTestneu {
public static testMethod void myTestMethod() {

        Account acc = new Account(Name = 'Test Test');
      
        {
        insert acc;

        List<Account> sendMail = [select id from account where (Name='Test Test') and id=:acc.id];
        
        test.startTest();

        HelperContactTrigger.sendEmail(sendMail);
        test.stopTest();
        System.assert(acc !=null);
        }
        }
        }
________________________________________________
public with sharing class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name='Neuer Kunde'];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){

            //check for Account
            if(con.PersonEmail == null && con.PersonEmail != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }
        //send mail
        Messaging.sendEmail(emails);

        return accounts;
    }
}

Thanks in advance.
 
good evening dear community, when I'm trying to execute a test class it wont do it because it's telling me: 
System.QueryException: List has no rows for assignment to SObject

@isTest
private class HelperContactTriggerTestneu {
public static testMethod void myTestMethod() {


        Account acc = new Account(Name = 'Frau Test Test');
      
        {
        insert acc;

        List<Account> sendMail = [select id from account where id=:acc.id];
        test.startTest();

        HelperContactTrigger.sendEmail(sendMail);
        test.stopTest();
        
        }
        }
        }

it belongs to this class :

public with sharing class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name=:'Sales: New Customer Email'];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){

            //check for Account
            if(con.PersonEmail == null && con.PersonEmail != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }

        //send mail
        Messaging.sendEmail(emails);

        return accounts;
    }
}

I created these to automatically send an email when a new account has been inserted.
Any advices how to make it work at all? because otherwise i cant deploy my test class, thanks in advance!
hello dear community, I was having trouble sending a PDF to an opportunity, whenever I want to send the PDF files via Adons, Salesforce is telling me the file is not found, even though I have the PDF file saved as a component as well as its apex class which generates the specific contact information on the pdf which is going to be sent.
Also I wanted to change some things on the component but it doesn't help it because it cannot be sent anyway so what do I do?
Have a look on the code maybe there's something wrong:
thanks in advance!

(component aka PDF)
<apex:component controller="MandatPDF" access="global">
<apex:attribute name="accountId" type="string" assignTo="{!actId}" description="to fetch account contacts"/>
<apex:attribute name="opId" type="string" assignTo="{!oppId}" description="to fetch account contacts"/>
        <apex:repeat value="{!AccConOppList}" var="AccCon">

<style type="text/css">
@page {
   size: 210mm 297mm; /* A4 width and height */
    margin:0mm;
    margin-top: 10mm;
    margin-left: 10mm;
    margin-right: 18mm;
    marging-bottom: 5mm;
}
HTML, body, p, {
    margin: 0;
    padding: 0;
    }
    
#pageNum:before {
    content: "Seite " counter(page);
}
.pageNum {
   float: right;
}    
/* div {border: 1px solid #000;} */
.document {
    min-height: 272mm;
    position: relative; 
    font-family: "Sans-Serif";
    font-size: 10pt;
    margin-left: 10mm;
}
.logo {
    margin-right: 5mm;
    margin-left: -5mm;
    float: left;
}
.headline {
    font-size: 19pt;
    margin-top: 9.5mm;
    float: left;
}
.kdref {
    font-size: 8pt;
    padding-top: 10mm;
    text-align: right;
}
.doctype {
    font-size: 16pt;
    margin-top: 10mm;
    margin-bottom: 10mm;
    border-bottom: 1px solid #000;
}

.text {
    text-align: justify;
    font-size: 11pt;
    line-height: 16pt;
}

.footer-right {
    float: right;
    text-align: right;
}

.footer { position:absolute; bottom:0; width:100%;}
.page-break { display:block; page-break-after:always;}
.clearing { clear: both; }
</style>

<!-- ################ Seite 1 ################ -->
<div class="document page-break">
    <div class="logo"><img src="https://c.eu3.content.force.com/servlet/servlet.ImageServer?id=015w0000001JOTq&oid=00Dw0000000Cy2g&lastMod=1411384891000" width="53mm"/></div>
    <div class="headline">Tarifoptimierung für Privatpatienten</div>
    <div class="kdref clearing">Kundenreferenz&nbsp;<apex:outputField value="{!AccCon.Account.Kundennummer_del__c}"/></div>
    <div class="doctype">Bevollmächtigung</div>
    <div class="text">
        <div style="padding-bottom: 10mm;">Hiermit erteile ich&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/>, geboren am&nbsp;<apex:outputField value="{!AccCon.Account.Geburtsdatum__c}"/>, wohnhaft in&nbsp;<apex:outputField value="{!AccCon.Account.PersonMailingCity}"/></div>
        
        <div style="float: left;width: 65mm;"><apex:outputField value="{!AccCon.Account.PersonMailingPostalCode}"/>&nbsp;<apex:outputField value="{!AccCon.Account.PersonMailingCity}"/></div><div style="float: left;width: 65mm;"><apex:outputField value="{!AccCon.Account.PersonMailingStreet}"/></div>
        <div style="float:left;font-size: 7pt; border-top: 1px solid #000; width: 60mm; margin-right: 5mm;">PLZ/Ort</div>
        <div style="float:left;font-size: 7pt; border-top: 1px solid #000; width: 60mm; margin-bottom: 5mm;">Straße</div>
        <div style="float:left; width: 60mm; margin-right: 5mm;">krankenversichert bei der</div>
        <div style="float:left;"><apex:outputText value="{!AccCon.Versicherungsgesellschaft__r.Name}"/></div>
        <div style="float:left; width: 60mm; font-size: 7pt; border-top: 1px solid #000;  margin-right: 20mm; margin-left: 65mm; margin-bottom: 3mm; padding: 0px;">Versicherungsgesellschaft</div>
        
        <div style="float:left; width: 60mm; margin-right: 5mm;">mit Versicherungsnummer</div>
        <div style="float:left;"><apex:outputText value="{!AccCon.Versicherungsscheinnummer__c}"/></div>
        <div style="float:left; width: 60mm; font-size: 7pt; border-top: 1px solid #000;  margin-right: 20mm; margin-left: 65mm; margin-bottom: 3mm; padding: 0px;"></div>
    </div>
    <div class="text clearing" style="padding-top: 1mm;">
        <p>der Mavencare GmbH die ausschließliche Vollmacht, Informationen zu der bestehenden Krankenversicherung des Auftraggebers beim Versicherer einzuholen und meine Interessen gegenüber dem Versicherer zu vertreten.</p>
        <p>Das umfasst unter anderem die Aufforderung an den Versicherer, für die von der Mavencare GmbH recherchierten Tarife, Berechnungen gemäß § 204 VVG vorzunehmen und diese vom Versicherer anzufordern. Des Weiteren ist die Mavencare GmbH bevollmächtigt, die Tarifumstellung im Auftrag des Auftraggebers gegenüber dem Versicherer einzuleiten und abzuwickeln und beim Versicherer Auskunft über den geltenden Tarif einzuholen.</p>
        <p>Sämtliche von der Mavencare GmbH angeforderten Unterlagen, Daten, Auskünfte und Informationen sind umgehend und direkt an die Mavencare GmbH zu übersenden.</p>
    </div>
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: 20mm; padding-top: 3px;">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/></span>
    </div>
    <div class="footer">
        <div style="float: left;font-size: 16pt; line-height: 22pt; margin-bottom: 4mm;">Bitte vorab per Email an<br/>oder per Telefax an</div>
        <div style="font-size: 16pt; line-height: 22pt;" class="footer-right">kontakt@mavencare.de<br/>040 - 1234567</div>
        <div style="border-top: 1px solid #000; padding-top: 4mm; font-size: 8pt;" class="clearing">Bitte Unterlagen im Original auf dem Postweg an:<br/><span style="font-size: 11pt;">Mavencare GmbH, Wittenbergener Weg 90, 22559 Hamburg</span></div>
    </div>
</div>


<!-- ################ Seite 2 ################ -->
<div class="document">
    <div class="logo"><img src="https://c.eu3.content.force.com/servlet/servlet.ImageServer?id=015w0000001JOTq&oid=00Dw0000000Cy2g&lastMod=1411384891000" width="53mm"/></div>
    <div class="headline">Tarifoptimierung für Privatpatienten</div>
    <div class="clearing" align="right" style="font-size: 8pt; padding-top: 10mm;"><span id="pageNum"></span></div>
    <div class="doctype">Dienstleistungsvertrag</div>
    <div class="text">
        <p>zwischen dem Kunden&nbsp;<apex:outputField value="{!AccCon.Account.Salutation}"/>&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/> und der Mavencare GmbH.</p>
        <p>Die Mavencare GmbH ist vom Kunden beauftragt, die Möglichkeit eines Tarifwechsels innerhalb der Krankenversicherungsgesellschaft des Kunden zu prüfen. Mavencare recherchiert im Namen des Kunden nach Einsparungsmöglichkeiten.</p>
        <p>Erst wenn sich der Kunde entschließt, eine der durch die Mavencare GmbH recherchierten Einsparungsmöglichkeiten durch Tarifumstellung in Auftrag zu geben, wird eine Vergütung der Dienstleistung berechnet. Die Vergütung wird fällig mit der Tarifumstellung. Die Höhe der Vergütung bemisst sich an der monatlichen Ersparnis. Die Differenz zwischen der alten und neuen Monatsprämie multipliziert mit dem Faktor&nbsp;<apex:outputField value="{!AccCon.MC_Faktor__c}"/> ergibt die Gesamtvergütung zuzüglich der gesetzlichen Mehrwertsteuer. Es kann vereinbart werden, dass die Vergütung in acht gleichen Monatsraten gezahlt wird.</P>
        <p>Sollte der Kunde keine der durch die Mavencare GmbH recherchierten Tarifumstellungen nutzen, ist die Dienstleistung der Mavencare GmbH kostenfrei.</p>
        <p>Der Kunde hat mit diesem Schreiben die geltenden Allgemeinen Geschäftsbedingungen, Datenschutzerklärung und Widerrufsbelehrung erhalten, zur Kenntnis genommen und anerkannt.</p>
    </div>
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: 20mm; padding-top: 0px;">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/></span>
    </div>

    <div style="padding-left: 100mm; padding-top: 10mm;">
        <img src="https://c.eu3.content.force.com/servlet/servlet.FileDownload?file=015w0000001JOj0" width="80mm"/>
    </div>     
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: -13mm; ">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift Werner Gerdts / Mavencare GmbH</span>
    </div>
    <div style="padding-left: 10mm; margin-top: -8mm; ">Hamburg, den&nbsp;<apex:outputText value=" {!TODAY()}" /></div>

    <div class="footer">
        <div style="float: left;font-size: 16pt; line-height: 22pt; margin-bottom: 4mm;">Bitte vorab per Email an<br/>oder per Telefax an</div>
        <div style="font-size: 16pt; line-height: 22pt;" class="footer-right">kontakt@mavencare.de<br/>040 - 1234567</div>
        <div style="border-top: 1px solid #000; padding-top: 4mm; font-size: 8pt;" class="clearing">Bitte Unterlagen im Original auf dem Postweg an:<br/><span style="font-size: 11pt;">Mavencare GmbH, Wittenbergener Weg 90, 22559 Hamburg</span></div>
    </div>
</div>

</apex:repeat>
</apex:component>


(apex class)
public class MandatPDF {

// This ID is set by a parameter in the email template
public String actId{get;set;}
public String oppId{get;set;}
//public string Faktor{get;set;}
    // Datum für PDF vorbereiten
    public String getIPDatum()
    {
        Date tmpDatum   =   Date.today();
        system.debug('### ' + tmpDatum + 'Date as String: ' + string.valueOf(tmpDatum));
        
        // return Date as String
        return string.valueOf(tmpDatum);
        
    }

    // Account Informationen sammeln
    public List<Opportunity> getAccConOppList()
    {
        // Wenn die Seite als Vorschau geöffnet wird, kommt die ID als Id Parameter
        if(ApexPages.currentPage().getParameters().get('id')!='' && ApexPages.currentPage().getParameters().get('id').startsWith('001'))
        {
            actId = ApexPages.currentPage().getParameters().get('id');
        }

         // When page is seen as preview, ID appears as ID parameter 
        if(ApexPages.currentPage().getParameters().get('opId')!='' && ApexPages.currentPage().getParameters().get('opId').startsWith('006'))
        {
            oppId = ApexPages.currentPage().getParameters().get('opId');
        }       
        
        system.debug('### actId:' +actId);
        system.debug('### oppId:' +oppId);
        
        return [SELECT MC_Faktor__c, Account.Id, Account.Owner.Name, Account.Owner.Phone, Account.Name, Account.Salutation, Account.Geburtsdatum__c, Account.PersonEmail, Account.textliche_Ansprache__pc, Account.Kundennummer_del__c, Account.akademischer_Titel__pc,Account.PersonMailingStreet, Account.PersonMailingCity, Account.PersonMailingPostalCode, Account.Owner.Benutzer_Unterschriften_URL__c, Account.Owner.Durchwahl__c, Account.doc_salutation__c, Account.doc_academictitle__c, Account.doc_firstname__c, Account.doc_lastname__c, Account.doc_street__c, Account.doc_birthdate__c, Account.doc_zipcode__c, Account.doc_city__c, Account.doc_salutationtext__c, Versicherungsgesellschaft__r.Name, Versicherungsscheinnummer__c FROM Opportunity WHERE Id=:oppId];
        //return [SELECT Id, Owner.Name, Owner.Phone, Name, Salutation, Geburtsdatum__c, PersonEmail, textliche_Ansprache__pc, Kundennummer_del__c, akademischer_Titel__pc,PersonMailingStreet, PersonMailingCity, PersonMailingPostalCode, Owner.Benutzer_Unterschriften_URL__c, Owner.Durchwahl__c, doc_salutation__c, doc_academictitle__c, doc_firstname__c, doc_lastname__c, doc_street__c, doc_birthdate__c, doc_zipcode__c, doc_city__c, doc_salutationtext__c FROM Account WHERE Id = :actId LIMIT 1];
    }

}
Hello dear community, I need some help programming an email trigger for my production, I already have a PDF as a visualforce-component and I want this to be sent automatically when a new account is added. Any advices ?

Thanks in advance :) 
Hello dear community, I already have an email template as a component and I just want to create a little bit of code, that sends this email to the account when he/she is added, any tipps or advices? thanks in advance:)